hsutter / cppfront

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

[BUG] Can't have `@enum` named `type` #878

Open JohelEGP opened 8 months ago

JohelEGP commented 8 months ago

Title: Can't have @enum named type.

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

type: @enum type = {
  range_difference;
}

declaration: @struct type = {
  name: std::string_view;
  type: type;
}

main: () = { }

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: The type of the added constants to be qualified to avoid clashing with Cpp2 syntax.

Actual result and error:

Output:

main.cpp2...
main.cpp2: error: a 'type ==' alias declaration must be followed by a type name
main.cpp2(1,1): error: while applying @enum - error attempting to add member:
    range_difference : type == 0;
main.cpp2(7,13): error: a user-defined type must have an = initializer (at ';')

See also: