qore
qore copied to clipboard
Runtime evaluation as a part of the parseCommit phase
Code:
Program p();
p.parsePending("
const f = x();
sub x() {
throw \"Uncommited code executed!\";
}
", "test");
try {
p.parseCommit();
} catch (ex) {
printf("%s\n", ex.err);
}
printf("x exists: %N\n", p.existsFunction("x"));
Output:
Uncommited code executed!
x exists: False
Note:
It is not clear what actually should happen in the example:
-
parseCommit()
commits the code first and then executes the initializers (i.e. it still throws, butx
would exist) -> what would the value off
be in this case? -
parseCommit()
commits the code but does not execute the initializers (i.e. it would not throw andx
would exist) -> when would bef
initialized?