qore icon indicating copy to clipboard operation
qore copied to clipboard

Runtime evaluation as a part of the parseCommit phase

Open tethal opened this issue 9 years ago • 0 comments

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, but x would exist) -> what would the value of f be in this case?
  • parseCommit() commits the code but does not execute the initializers (i.e. it would not throw and x would exist) -> when would be f initialized?

tethal avatar Oct 08 '15 11:10 tethal