Skip to content

Commit 9d1839a

Browse files
committed
Some IMMUTABLE fixes
1 parent 0c7a4dd commit 9d1839a

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/objects.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ void SET_TYPE_OBJ(Obj obj, Obj type)
194194
break;
195195
#endif
196196
case T_PREC:
197+
if (!IS_MUTABLE_OBJ(obj)) {
198+
ErrorMayQuit("cannot change type of an immutable %s", (Int)TNAM_OBJ(obj), 0);
199+
}
197200
#ifdef HPCGAP
198201
MEMBAR_WRITE();
199202
#endif
@@ -1181,6 +1184,9 @@ static Obj FuncSET_TYPE_COMOBJ(Obj self, Obj obj, Obj type)
11811184
{
11821185
switch (TNUM_OBJ(obj)) {
11831186
case T_PREC:
1187+
if (!IS_MUTABLE_OBJ(obj)) {
1188+
ErrorMayQuit("You can't make a component object from an immutable %s", (Int)TNAM_OBJ(obj), 0);
1189+
}
11841190
case T_COMOBJ:
11851191
#ifdef HPCGAP
11861192
case T_AREC:

tst/testinstall/kernel/objects.tst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Error, You can't make a component object from a boolean or fail
2828
gap> SET_TYPE_COMOBJ([], fail);
2929
Error, You can't make a component object from a empty plain list
3030
gap> SET_TYPE_COMOBJ(MakeImmutable(rec()), fail);
31-
Error, You can't make a component object from a record (plain)
31+
Error, You can't make a component object from an immutable record (plain)
3232
gap> x:=rec();;
3333
gap> SET_TYPE_COMOBJ(x, t1c);
3434
<object>

0 commit comments

Comments
 (0)