#UE7 - Test 3 fails, expected no error, but test has unterminated string?

I’m stuck on Stage #UE7, specifically test-3 fails, as it expects an exit code 0, despite the test having an unterminated string (ending quotation mark “ is behind comment //), or am I missing something?

Relevant logs:

[tester::#UE7] [test-3] Running test case: 3
[tester::#UE7] [test-3] Writing contents to ./test.lox:
[tester::#UE7] [test-3.lox] "foo <|TAB|>bar 123 // hello world!"
[tester::#UE7] [test-3] $ ./your_program.sh tokenize test.lox
[your_program] Logs from your program will appear here!
[your_program] [line 1] Error: Unterminated string.
[your_program] EOF  null
[tester::#UE7] [test-3] expected no error (exit code 0), got exit code 65
[tester::#UE7] [test-3] Test failed

Hey @MwBoesgaard, that shouldn’t be an unterminated string.

In Lox, everything inside a string is treated as literal text, so “//” is just two slashes, not the start of a comment.

You can check the official implementation for reference:
https://github.com/britannio/lox/blob/main/jlox/src/YOmain/java/dev/britannio/lox/Scanner.java

You can also verify with an unofficial Lox playground:

Let me know if you’d like any further clarification!

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