Invalid error for test case

I’m stuck on Stage #wz8

I’ve tried this stage:

```For example, if test.lox contains the following:

(72 +)

The tester will run your program like this:

$ ./your_program.sh parse test.lox
[line 1] Error at ')': Expect expression.

The tester will assert that the exit code is 65.```

and my output is correct!

[line 1] Error at ')': Expect expression.

Here are my logs:

[tester::#WZ8] [test-1] Running test case: 1
[tester::#WZ8] [test-1] Writing contents to ./test.lox:
[tester::#WZ8] [test-1] [test.lox] "baz
[tester::#WZ8] [test-1] $ ./your_program.sh parse test.lox
[your_program] [line 1] Error: Unterminated string.
[tester::#WZ8] [test-1] ✓ 1 line(s) match on stdout
[tester::#WZ8] [test-1] ✓ Received exit code 65.
[tester::#WZ8] [test-2] Running test case: 2
[tester::#WZ8] [test-2] Writing contents to ./test.lox:
[tester::#WZ8] [test-2] [test.lox] (81 +)
[tester::#WZ8] [test-2] $ ./your_program.sh parse test.lox
[your_program] [line 1] Error at ')': Expect expression.
[tester::#WZ8] [test-2] 𐄂 [line 1] Error at ')': Expect expression.
[tester::#WZ8] [test-2] Expected line #1 on stdout to be "", got "[line 1] Error at ')': Expect expression."
[tester::#WZ8] [test-2] Test failed```

Why I got
Expected line #1 on stdout to be "", got "[line 1] Error at ')': Expect expression."

if it should be [line 1] Error at ')': Expect expression.
!!!

And here's a snippet of my code: 

```rust
        "parse" => {
            let mut parser = Parser::new(&tokens);
            parser.parse();

            if !parser.errors.is_empty() {
                for error in parser.errors {
                    println!("{error}");
                }
                exit(65)
            }
            for expr in parser.exprs {
                println!("{}", expr);
            }
        }

The problem is that you are logging the error to STD OUT, whereas the error messages should be logged to STD ERR, and the STD OUT should remain blank.

Try using write! macro with the appropriate stream to log the messages instead of using println! which by default writes to the STD OUT stream.

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