hsutter / cppfront

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

[BUG] Digit separator doesn't parse #862

Closed JohelEGP closed 10 months ago

JohelEGP commented 11 months ago

Title: Digit separator doesn't parse.

Minimal reproducer (https://cpp2.godbolt.org/z/Pn4zd7MeM):

niam: () = { _ = 0'1; } // Not OK.
main: () = {
  _ = 0'1; // OK
}

Commands: ```bash cppfront main.cpp2 clang++18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -Werror=unused-value -Werror=unused-parameter -I . main.cpp ```

Expected result: Both to work.

Actual result and error:

main.cpp2...
main.cpp2(5,0): error: end of file reached with 1 missing } to match earlier { on line 1
ntrel commented 11 months ago

This causes the same error:

  if 1 { _ = 0'1; }

Seems to be caused by this line: https://github.com/hsutter/cppfront/blob/c1d3e0edc8b2e2a2c035f68b6c0012c5b7049a07/source/io.h#L784

hsutter commented 10 months ago

Yup, that was the offending line. Thanks!