Skip to content

Commit 59b05e7

Browse files
committed
kernel: use IS_MUTABLE_OBJ in UNB_LIST/ASS_LIST/ASSS_LIST
1 parent 7bdf2ab commit 59b05e7

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

src/lists.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,7 @@ void UNBB_LIST(Obj list, Obj pos);
465465
EXPORT_INLINE void UNB_LIST(Obj list, Int pos)
466466
{
467467
GAP_ASSERT(pos > 0);
468-
UInt tnum = TNUM_OBJ(list);
469-
if (FIRST_LIST_TNUM <= tnum && tnum <= LAST_LIST_TNUM &&
470-
(tnum & IMMUTABLE)) {
468+
if (!IS_MUTABLE_OBJ(list)) {
471469
ErrorMayQuit("List Unbind: <list> must be a mutable list", 0, 0);
472470
}
473471
(*UnbListFuncs[TNUM_OBJ(list)])(list, pos);
@@ -502,9 +500,7 @@ EXPORT_INLINE void ASS_LIST(Obj list, Int pos, Obj obj)
502500
{
503501
GAP_ASSERT(pos > 0);
504502
GAP_ASSERT(obj != 0);
505-
UInt tnum = TNUM_OBJ(list);
506-
if (FIRST_LIST_TNUM <= tnum && tnum <= LAST_LIST_TNUM &&
507-
(tnum & IMMUTABLE)) {
503+
if (!IS_MUTABLE_OBJ(list)) {
508504
ErrorMayQuit("List Assignment: <list> must be a mutable list", 0, 0);
509505
}
510506
(*AssListFuncs[TNUM_OBJ(list)])(list, pos, obj);
@@ -550,9 +546,7 @@ EXPORT_INLINE void ASSS_LIST(Obj list, Obj poss, Obj objs)
550546
GAP_ASSERT(IS_POSS_LIST(poss));
551547
GAP_ASSERT(IS_DENSE_LIST(objs));
552548
GAP_ASSERT(LEN_LIST(poss) == LEN_LIST(objs));
553-
UInt tnum = TNUM_OBJ(list);
554-
if (FIRST_LIST_TNUM <= tnum && tnum <= LAST_LIST_TNUM &&
555-
(tnum & IMMUTABLE)) {
549+
if (!IS_MUTABLE_OBJ(list)) {
556550
ErrorMayQuit("List Assignments: <list> must be a mutable list", 0, 0);
557551
}
558552
(*AsssListFuncs[TNUM_OBJ(list)])(list, poss, objs);

tst/testinstall/kernel/lists.tst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Error, no 1st choice method found for `IsBound[]' on 2 arguments
2929

3030
#
3131
gap> UNB_LIST(1,2);
32-
Error, Unbind: <list> must be a list (not the integer 1)
32+
Error, List Unbind: <list> must be a mutable list
3333
gap> UNB_LIST([1],1);
3434
gap> UNB_LIST([1],2);
3535

@@ -79,7 +79,7 @@ gap> ELMS_LIST_DEFAULT([1,2,3],[1..2]);
7979

8080
#
8181
gap> ASS_LIST(1,1,1);
82-
Error, List Assignments: <list> must be a list (not the integer 1)
82+
Error, List Assignment: <list> must be a mutable list
8383
gap> l:=[];; ASS_LIST(l,1,1); l;
8484
[ 1 ]
8585

@@ -89,7 +89,7 @@ Error, List Assignments: <rhss> must be a dense list (not the integer 1)
8989
gap> ASSS_LIST([1],1,[1]);
9090
Error, List Assignments: <poss> must be a dense list of positive integers
9191
gap> ASSS_LIST(1,[1],[1]);
92-
Error, List Assignments: <list> must be a list (not the integer 1)
92+
Error, List Assignments: <list> must be a mutable list
9393
gap> l:=[];; ASSS_LIST(l,[1],[1]); l;
9494
[ 1 ]
9595

@@ -99,7 +99,7 @@ Error, List Assignments: <rhss> must be a dense list
9999
gap> ASSS_LIST_DEFAULT([1],1,[1]);
100100
Error, List Assignments: <poss> must be a dense list of positive integers
101101
gap> ASSS_LIST_DEFAULT(1,[1],[1]);
102-
Error, List Assignments: <list> must be a list (not the integer 1)
102+
Error, List Assignment: <list> must be a mutable list
103103
gap> l:=[];; ASSS_LIST_DEFAULT(l,[1],[1]); l;
104104
[ 1 ]
105105

0 commit comments

Comments
 (0)