My test fails on a testcase, but the printed test case has a character (sequence) i dont know how to interpret. Clearly its not a space character, or the return would live inside the comment.
But a return could have just been a newline.
// Return statements are not allowed at the top-level<|SPACE|>return; // This should be a compile error
I dont know what to put in my testfile to reproduce this.
I could but my point is that i dont understand the testcase. I cannot reproduce the test.lox file locally, so i cannot gdb my program.
The test.lox file from the testcase in question, is
// Return statements are allowed within function scope
return "at function scope is ok";
}
// Return statements are not allowed at the top-level<|SPACE|>return; // This should be a compile error
I dont know what the “<|SPACE|>” should represent. It should be some whitespace character sequence. But its clearly the intention of the testcase that the return after the <|SPACE|> is to be interpreted, and not part of the comment.
Ahh, got it. The testcase is actually meant to look like this:
fun foo() {
// Return statements are allowed within function scope
return "at function scope is ok";
}
// Return statements are not allowed at the top-level
return; // This should be a compile error
We’ll look into why the it got mangled and follow up once it’s been fixed. Thanks for highlighting it!
okay. cool. thanks.
Thing is. I already tried your suggested testfile, and my interpreter version handles that gracefully. But it actually segfaults during the testcase, and i cant figure out for the life of me what could cause that.
I’ll try and print the AST after parsing, to see what actually comes out. In the end its only the tokenlist that matters what goes into the interpreter.
Anyway. Thanks for your help