diff --git a/lib/global.gd b/lib/global.gd index bdd99af192..e256dbb7f8 100644 --- a/lib/global.gd +++ b/lib/global.gd @@ -197,9 +197,7 @@ DeclareGlobalFunction("MakeReadWriteGlobal"); ## ## MakeConstantGlobal ( name ) marks the global variable named ## by the string name as constant. A constant variable can never -## be changed or made read-write. Constant variables can only take an -## integer value, true or false. There is a limit on -## the size of allowed integers. +## be reassigned or made read-write again. ##

## A warning is given if name is already constant. ## diff --git a/src/gvars.c b/src/gvars.c index 1053e73e61..f50c177de9 100644 --- a/src/gvars.c +++ b/src/gvars.c @@ -797,12 +797,6 @@ void MakeReadOnlyGVar ( */ void MakeConstantGVar(UInt gvar) { - Obj val = ValGVar(gvar); - if (!IS_INTOBJ(val) && val != True && val != False) { - ErrorMayQuit( - "Variable: '%g' must be assigned a small integer, true or false", - (Int)NameGVar(gvar), 0); - } SetGVarWriteState(gvar, GVarConstant); } diff --git a/src/read.c b/src/read.c index 7327ba7f7f..0c025a46e9 100644 --- a/src/read.c +++ b/src/read.c @@ -856,16 +856,19 @@ static void ReadCallVarAss(ReaderState * rs, TypSymbolSet follow, Char mode) if (mode == 'r' || (mode == 'x' && rs->s.Symbol != S_ASSIGN)) { Obj val = ValAutoGVar(ref.var); TRY_IF_NO_ERROR { - if (val == True) + if (val == True) { IntrTrueExpr(&rs->intr); - else if (val == False) + return; + } + else if (val == False) { IntrFalseExpr(&rs->intr); - else if (IS_INTOBJ(val)) + return; + } + else if (IS_INTOBJ(val)) { IntrIntObjExpr(&rs->intr, val); - else - SyntaxError(&rs->s, "Invalid constant variable"); + return; + } } - return; } } diff --git a/tst/testinstall/constant.tst b/tst/testinstall/constant.tst index 61f7a70aea..7cf9c401a2 100644 --- a/tst/testinstall/constant.tst +++ b/tst/testinstall/constant.tst @@ -44,12 +44,11 @@ true gap> Unbind(testvar); Error, Variable: 'testvar' is constant -# Try making a global var constants whose value is not eligible +# make a global var constants whose value is not a small integer, true or false gap> newtestvar := fail;; gap> MakeConstantGlobal("newtestvar"); -Error, Variable: 'newtestvar' must be assigned a small integer, true or false gap> IsConstantGlobal("newtestvar"); -false +true # some more tests with constant gvars with boolean value gap> booltruevar := true;;