Interpreter #EH3 test failure. Dont know how to interpret <|SPACE|> from test program, to reproduce

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.

Hey @InvalidName-pfft, could you upload your code to GitHub and share the link? It will be much easier to debug if I can run it directly.

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.

(Thanks for the quick response btw)

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. :slight_smile:
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 :+1:

@InvalidName-pfft We’ve fixed the testcase in this PR. Thanks again for highlighting the issue!

Let me know if you need more debugging help!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.