MP7 not passing although it passes on my machine with the same test data in the file

Please checkout code in this repository:

remote: [compile] Moved ./.codecrafters/run.sh → ./your_program.sh
remote: [compile] Compilation successful.
remote:
remote: [tester::#MP7] Running tests for Stage #MP7 (Scanning: Assignment & equality Operators)
remote: [tester::#MP7] [test-1] Running test case: 1
remote: [tester::#MP7] [test-1] Writing contents to ./test.lox:
remote: [tester::#MP7] [test-1.lox] =
remote: [tester::#MP7] [test-1] $ ./your_program.sh tokenize test.lox
remote: [your_program] EQUAL = null
remote: [your_program] EOF null
remote: [tester::#MP7] [test-1] ✓ 2 line(s) match on stdout
remote: [tester::#MP7] [test-1] ✓ Received exit code 0.
remote: [tester::#MP7] [test-2] Running test case: 2
remote: [tester::#MP7] [test-2] Writing contents to ./test.lox:
remote: [tester::#MP7] [test-2.lox] ==
remote: [tester::#MP7] [test-2] $ ./your_program.sh tokenize test.lox
remote: [your_program] EQUAL = null
remote: [your_program] EQUAL = null
remote: [your_program] EOF null
remote: [tester::#MP7] [test-2] 𐄂 EQUAL = null
remote: [tester::#MP7] [test-2] Expected line #1 on stdout to be “EQUAL_EQUAL == null”, got “EQUAL = null”
remote: [tester::#MP7] [test-2] Test failed (try setting ‘debug: true’ in your codecrafters.yml to see more details)

Hey @z4nsh1n, I ran the code locally and it did not produced the expected result:

Here’s what the correct output should look like:

There might be a few issues at play. The first one I noticed is an edge case: the comparison probably needs to be <=:

Let me know if you’d like further assistance!

Hey @andy1li,

Thanks for looking at my code.

If I use <= I get this panic error:

zanshin 16:23:27 ~/code/zig/codecrafters-interpreter-zig master $ zig build run – tokenize assignment_and_equal.lox
EQUAL_EQUAL = null
thread 24683 panic: index out of bounds: index 4, len 3
/home/zanshin/code/zig/codecrafters-interpreter-zig/src/main.zig:64:40: 0x10e2020 in main (main)
const token = file_contents[idx .. idx + 1];
^
/home/zanshin/.zvm/0.14.0/lib/std/start.zig:656:37: 0x10df70a in posixCallMainAndExit (main)
const result = root.main() catch |err| {
^
/home/zanshin/.zvm/0.14.0/lib/std/start.zig:271:5: 0x10df2bd in _start (main)
asm volatile (switch (native_arch) {
^
???:?:?: 0x0 in ??? (???)
run
└─ run main failure
error: the following command terminated unexpectedly:
/home/zanshin/code/zig/codecrafters-interpreter-zig/.zig-cache/o/ee9be5f3bbaa20429159599d18078bb7/main tokenize assignment_and_equal.lox
Build Summary: 1/3 steps succeeded; 1 failed
run transitive failure
└─ run main failure
error: the following build command failed with exit code 1:
/home/zanshin/code/zig/codecrafters-interpreter-zig/.zig-cache/o/97749b66c265ca29509748378a07701f/build /home/zanshin/.zvm/0.14.0/zig /home/zanshin/.zvm/0.14.0/lib /home/zanshin/code/zig/codecrafters-interpreter-zig /home/zanshin/code/zig/codecrafters-interpreter-zig/.zig-cache /home/zanshin/.cache/zig --seed 0x2ee7b0d1 -Zaebd6382d7b89e6c run – tokenize assignment_and_equal.lox

If I run the original code on my machine It parses just fine:

zanshin 16:24:45 ~/code/zig/codecrafters-interpreter-zig master $ zig build run – tokenize assignment_and_equal.lox
EQUAL = null
LEFT_BRACE { null
EQUAL_EQUAL = null
EQUAL = null
RIGHT_BRACE } null
EOF null

assignment_and_equal.lox:
={===}

Any futher input would be really appreciated.