Add more "const" debugging messages.

This commit is contained in:
Dianne Skoll
2025-05-23 13:38:38 -04:00
parent 7e5dc26ee5
commit edf26eaa14
3 changed files with 19 additions and 10 deletions

View File

@@ -570,6 +570,9 @@ eval_builtin(expr_node *node, Value *locals, Value *ans, int *nonconst)
/* Special case of const cunction */
if (!strcmp(f->name, "const")) {
if (*nonconst) {
nonconst_debug(0, tr("Non-constant expression converted to constant by `const' built-in function"));
}
*nonconst = 0;
}
/* Don't allow retval to be destroyed! */

View File

@@ -16466,10 +16466,14 @@ IF today() < '1990-01-01'
../tests/test.rem(1556): Potential variable assignment considered non-constant because of context
ENDIF
dump -c a
set b const(today())
../tests/test.rem(1559): Non-constant built-in function `today' makes expression non-constant
../tests/test.rem(1559): Non-constant expression converted to constant by `const' built-in function
dump -c a b
Variable Value
a 1
b 1991-02-16 <const>
DEBUG -n
@@ -16491,16 +16495,16 @@ Variable Value
a 1991-02-17
set a eval("1 +")
eval("1 +") => ../tests/test.rem(1569): Unexpected end of line
eval("1 +") => ../tests/test.rem(1570): Unexpected end of line
1 +
^-- here
Unexpected end of line
set a eval("1/0")
eval("1/0") => 1 / 0 => Division by zero
../tests/test.rem(1570): `/': Division by zero
../tests/test.rem(1571): `/': Division by zero
Division by zero
set a eval("1 / / 2")
eval("1 / / 2") => ../tests/test.rem(1571): Illegal character `/'
eval("1 / / 2") => ../tests/test.rem(1572): Illegal character `/'
1 / / 2
^-- here
Illegal character
@@ -16520,7 +16524,7 @@ set a shell("echo foo")
shell("echo foo") => "foo"
set a eval("shell(\"echo foo\")")
eval("shell(\"echo foo\")") => shell("echo foo") => RUN disabled
../tests/test.rem(1578): shell(): RUN disabled
../tests/test.rem(1579): shell(): RUN disabled
RUN disabled
set a shell("echo foo")
shell("echo foo") => "foo"
@@ -16533,8 +16537,8 @@ Leaving UserFN i() => "foo"
set a eval("i()")
eval("i()") => Entering UserFN i()
shell("echo foo") => RUN disabled
../tests/test.rem(1583): shell(): RUN disabled
../tests/test.rem(1581): [#0] In function `i'
../tests/test.rem(1584): shell(): RUN disabled
../tests/test.rem(1582): [#0] In function `i'
Leaving UserFN i() => RUN disabled
RUN disabled
set a i()
@@ -16547,13 +16551,13 @@ set b eval(a)
a => "eval(\"1\")+ shell(\"ls\")"
eval("eval(\"1\")+ shell(\"ls\")") => eval("1") => 1
shell("ls") => RUN disabled
../tests/test.rem(1587): shell(): RUN disabled
../tests/test.rem(1588): shell(): RUN disabled
RUN disabled
DEBUG -x
DEBUG -e
../tests/test.rem(1595): eval(): Too many recursive function calls
../tests/test.rem(1596): eval(): Too many recursive function calls
Base: 1991-02-09
Base: 1991-02-09
Variable hash table statistics:
@@ -24950,6 +24954,7 @@ TRANSLATE "Missing REM type; assuming MSG" ""
TRANSLATE "No Adar A in %d" ""
TRANSLATE "No substition function `%s' defined" ""
TRANSLATE "Non-constant built-in function `%s' makes expression non-constant" ""
TRANSLATE "Non-constant expression converted to constant by `const' built-in function" ""
TRANSLATE "Not setting $OnceFile: Already processed a reminder with a ONCE clause" ""
TRANSLATE "OMIT: UNTIL not allowed; did you mean THROUGH?" ""
TRANSLATE "OMITFUNC counts as a non-constant expression" ""

View File

@@ -1556,7 +1556,8 @@ IF today() < '1990-01-01'
SET a 2
ENDIF
dump -c a
set b const(today())
dump -c a b
DEBUG -n