Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/compiled.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ static inline void CHECK_FUNC(Obj obj)
else ASSB_LIST(list, p, rhs);

#define C_ASS_LIST_FPL(list,p,rhs) \
if ( IS_POS_INTOBJ(p) && TNUM_OBJ(list) == T_PLIST ) { \
if ( IS_POS_INTOBJ(p) && TNUM_OBJ(list) == T_PLIST && \
IS_MUTABLE_OBJ(list) ) { \
if ( LEN_PLIST(list) < INT_INTOBJ(p) ) { \
GROW_PLIST( list, (UInt)INT_INTOBJ(p) ); \
SET_LEN_PLIST( list, INT_INTOBJ(p) ); \
Expand All @@ -136,7 +137,8 @@ static inline void CHECK_FUNC(Obj obj)
}

#define C_ASS_LIST_FPL_INTOBJ(list,p,rhs) \
if ( IS_POS_INTOBJ(p) && TNUM_OBJ(list) == T_PLIST) { \
if ( IS_POS_INTOBJ(p) && TNUM_OBJ(list) == T_PLIST && \
IS_MUTABLE_OBJ(list) ) { \
if ( LEN_PLIST(list) < INT_INTOBJ(p) ) { \
GROW_PLIST( list, (UInt)INT_INTOBJ(p) ); \
SET_LEN_PLIST( list, INT_INTOBJ(p) ); \
Expand Down
2 changes: 1 addition & 1 deletion src/hpc/threadapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2023,7 +2023,7 @@ MigrateObjects(int count, Obj * objects, Region * target, int retype)
// they need to be sorted, as sorting upon access may prove impossible.
for (i = 0; i < count; i++) {
Obj obj = objects[i];
if (TNUM_OBJ(obj) == T_PREC) {
if (TNUM_OBJ(obj) == T_PREC && IS_MUTABLE_OBJ(obj)) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChrisJefferson sorry I had forgotten to put this in here -- added after your review, but I hope it is fine, as it is in the same spirit as the rest of the changes in here.

SortPRecRNam(obj);
}
SET_REGION(obj, target);
Expand Down
2 changes: 1 addition & 1 deletion src/vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ static ExecStatus ExecAssList(Expr stat)
p = INT_INTOBJ(pos);

// special case for plain list
if ( TNUM_OBJ(list) == T_PLIST ) {
if ( TNUM_OBJ(list) == T_PLIST && IS_MUTABLE_OBJ(list) ) {
if ( LEN_PLIST(list) < p ) {
GROW_PLIST( list, p );
SET_LEN_PLIST( list, p );
Expand Down
13 changes: 12 additions & 1 deletion tst/testinstall/listindex.tst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
##
##
##
#@local foo,l,o,r,res,s,t,x
#@local f,foo,l,o,r,res,s,t,x
gap> START_TEST("listindex.tst");

# custom list implementation, pretending to have infinite length
Expand Down Expand Up @@ -408,5 +408,16 @@ function ( x )
return 1;
end

# assignment inside a function to an immutable list that the kernel has not
# classified beyond "plain list"
gap> l := [ 1, "a", 3 ];; l[5] := 1;; Unbind(l[5]);; MakeImmutable(l);;
gap> f := function(l, i) l[i] := 0; end;;
gap> f(l, 1);
Error, List Assignment: <list> must be a mutable list
gap> f(l, 5);
Error, List Assignment: <list> must be a mutable list
gap> l;
[ 1, "a", 3 ]

# that's all, folks
gap> STOP_TEST("listindex.tst");
Loading