Skip to content

Commit

Permalink
Add type checks to Concatenation
Browse files Browse the repository at this point in the history
In particular, this lets the undefined expression `Concatenation( [ 1 ] )`
throw an error instead of returning `1`.
  • Loading branch information
zickgraf committed Mar 29, 2023
1 parent a78e3d2 commit 1f6de1c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/list.gi
Original file line number Diff line number Diff line change
Expand Up @@ -2084,8 +2084,14 @@ InstallGlobalFunction( Concatenation, function ( arg )
if Length( arg ) = 0 then
return [ ];
fi;
if not IsList( arg[1] ) then
Error( "Concatenation: arguments must be lists" );
fi;
res := ShallowCopy( arg[1] );
for i in [ 2 .. Length( arg ) ] do
if not IsList( arg[i] ) then
Error( "Concatenation: arguments must be lists" );
fi;
Append( res, arg[i] );
od;
return res;
Expand Down

0 comments on commit 1f6de1c

Please sign in to comment.