diff --git a/lib/coll.gi b/lib/coll.gi index 5ad14ee5eb..2bf23b5aec 100644 --- a/lib/coll.gi +++ b/lib/coll.gi @@ -727,8 +727,8 @@ InstallGlobalFunction( List, function( arg ) local tnum, C, func, res, i, elm, l; l := Length(arg); - if l = 0 then - Error( "usage: List( [, ] )" ); + if l = 0 or l > 2 then + ErrorNoReturn( "usage: List( [, ] )" ); fi; tnum:= TNUM_OBJ_INT( arg[1] ); if FIRST_LIST_TNUM <= tnum and tnum <= LAST_LIST_TNUM then diff --git a/tst/testinstall/listgen.tst b/tst/testinstall/listgen.tst index 278f262046..bb8eefdae0 100644 --- a/tst/testinstall/listgen.tst +++ b/tst/testinstall/listgen.tst @@ -12,6 +12,14 @@ gap> List( [ 1 .. 10 ], x -> x^2 ); [ 1, 4, 9, 16, 25, 36, 49, 64, 81, 100 ] gap> List( [ 2, 1, 2, 1 ], x -> x - 1 ); [ 1, 0, 1, 0 ] +gap> List(); +Error, usage: List( [, ] ) +gap> List([1..10], x->x^2, "extra argument"); +Error, usage: List( [, ] ) +gap> List([,1,,3,4], x->x>2); +[ , false,, true, true ] +gap> IsMutable(List([1,2,3],x->x^2)); +true gap> Flat( List( [ 1 .. 5 ], x -> [ 1 .. x ] ) ); [ 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5 ] gap> Reversed( [ 1, 2, 1, 2 ] );