hsutter / cppfront

A personal experimental C++ Syntax 2 -> Syntax 1 compiler
Other
5.39k stars 232 forks source link

[BUG] Checking backslash (`'\\'`) in an if check causes erroneous cppfront compiler errors #892

Closed JakeShirley closed 8 months ago

JakeShirley commented 8 months ago

Describe the bug Checking a backslash ('\') character value in an if check causes cppfront to think there are brace mismatches.

To Reproduce Example code:

main: () -> int = {
    testValue : char = '\\';

    if testValue == '\\' {
        return 1;
    }

    return 0;
}

Expected Behavior: Code compiles and runs, or alternatively gives an accurate error of what and why the error occurred.

Observed Results: cppfront fails with the following error:

main.cpp2:9:0: error: closing } does not match a prior {
main.cpp2: error: unexpected end of source file

Additional context A friend and I are using cppfront in Advent of Code this year and both (separately) hit this on the 2023 Day 16 problem 😅 .

JohelEGP commented 8 months ago

It seems like you're using an outdated version. It works on Compiler Explorer: https://cpp2.godbolt.org/z/fsvzKefsr.

JakeShirley commented 8 months ago

Welp, you're right!

Updating to the latest seems to make the error go away.

Thanks for the quick reply, closing.

JakeShirley commented 8 months ago

To close the loop, this was fixed in c1d3e0edc8b2e2a2c035f68b6c0012c5b7049a07