# Interpreter #FB4: test is bugged

**URL:** <https://forum.codecrafters.io/t/interpreter-fb4-test-is-bugged/7332>\
**Category:** Challenges\
**Tags:** challenge:interpreter\
**Created:** [March 22, 2025, 12:05pm UTC](https://forum.codecrafters.io/t/interpreter-fb4-test-is-bugged/7332 "2025-03-22T12:05:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vsiles](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/vsiles/32/1696_2.png) [@vsiles](https://forum.codecrafters.io/u/vsiles)\
**Post date:** [March 22, 2025, 12:05pm UTC](https://forum.codecrafters.io/t/interpreter-fb4-test-is-bugged/7332/1 "2025-03-22T12:05:02Z")

</div>

On stage FB4 of the interpreter, one of the test seems bugged. Here is the output I got:

```auto
remote: [tester::#FB4] [test-4.lox] // This program tests that when a variable is declared in an outer scope,
remote: [tester::#FB4] [test-4.lox] // it can be used in an inner scope
remote: [tester::#FB4] [test-4.lox] // But when a variable is declared in an inner scope,
remote: [tester::#FB4] [test-4.lox] // it can't be used in an outer scope
remote: [tester::#FB4] [test-4.lox] {
remote: [tester::#FB4] [test-4.lox] var quz = "outer quz";
remote: [tester::#FB4] [test-4.lox] var bar = "outer bar";
remote: [tester::#FB4] [test-4.lox] {
remote: [tester::#FB4] [test-4.lox] quz = "modified quz";
remote: [tester::#FB4] [test-4.lox] var bar = "inner bar";
remote: [tester::#FB4] [test-4.lox] print quz;
remote: [tester::#FB4] [test-4.lox] print bar;
remote: [tester::#FB4] [test-4.lox] }
remote: [tester::#FB4] [test-4.lox] print quz;
remote: [tester::#FB4] [test-4.lox] print bar;
remote: [tester::#FB4] [test-4.lox] }
remote: [tester::#FB4] [test-4.lox] print bar;
remote: [tester::#FB4] [test-4.lox]
remote: [tester::#FB4] [test-4] $ ./your_program.sh run test.lox
remote: [your_program] modified quz
remote: [your_program] inner bar
remote: [your_program] modified quz
remote: [your_program] outer bar
remote: [your_program] Undefined variable 'bar'.
remote: [your_program] [line 17]
remote: [tester::#FB4] [test-4] ✓ modified quz
remote: [tester::#FB4] [test-4] ✓ inner bar
remote: [tester::#FB4] [test-4] ✓ modified quz
remote: [tester::#FB4] [test-4] ✓ outer bar
remote: [tester::#FB4] [test-4] ! Undefined variable 'bar'.
remote: [tester::#FB4] [test-4] Expected last stdout line to be "outer bar", but found extra line: "Undefined variable 'bar'."
remote: [tester::#FB4] [test-4] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)

```

The `print bar;` on the last line should be an error and not print `"outer bar"` because it is defined in a nested scope, not at top level.

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [March 22, 2025, 1:49pm UTC](https://forum.codecrafters.io/t/interpreter-fb4-test-is-bugged/7332/5 "2025-03-22T13:49:01Z")

</div>

Hey @vsiles, sorry the error message is a bit confusing.

The tester is actually behaving correctly. It expects `outer bar` to be the last line of stdout, meaning nothing should come after it.

However, it’s receiving an **extra line** in stdout: `Undefined variable 'bar'.`.

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/b/b377afdc21ffb29367079b7884294000a0d93f88.png)

**Fix:** Print `Undefined variable 'bar'.` to **stderr** instead of **stdout**.

We’re also tweaking the error message in [this PR](https://github.com/codecrafters-io/interpreter-tester/pull/76).

---

<div class="post-metadata">

**Author:** ![vsiles](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/vsiles/32/1696_2.png) [@vsiles](https://forum.codecrafters.io/u/vsiles)\
**Post date:** [March 22, 2025, 1:57pm UTC](https://forum.codecrafters.io/t/interpreter-fb4-test-is-bugged/7332/6 "2025-03-22T13:57:08Z")

</div>

Oh I see. Thank you for the clarification !

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [March 27, 2025, 1:57pm UTC](https://forum.codecrafters.io/t/interpreter-fb4-test-is-bugged/7332/7 "2025-03-27T13:57:12Z")

</div>

Closed on March 27, 2025, 1:57pm UTC

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