Skip to content

Commit 65fcd0f

Browse files
authored
Add diagnostics for type alias to a wildcard, closes #357 (#360)
In the current implementation of cppfront (f83ca9) the following code: ```cpp alias5: type == _; alias6: type == auto; ``` Generates succesfuly: ```cpp using alias5 = auto; using alias6 = auto; ``` Which is invalid cpp1 code. After this change the alias to wildcard will generate the following error: ``` error: a 'type ==' alias declaration must be followed by a type name (not a wildcard _ nor auto) ``` All regression tests pass. Closes #357
1 parent 19132f1 commit 65fcd0f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

source/parse.h

+10
Original file line numberDiff line numberDiff line change
@@ -5628,6 +5628,16 @@ class parser
56285628
);
56295629
return {};
56305630
}
5631+
if (
5632+
t->is_wildcard()
5633+
|| ( t->get_token() && t->get_token()->to_string(true) == "auto" )
5634+
) {
5635+
errors.emplace_back(
5636+
curr().position(),
5637+
"a 'type ==' alias declaration must be followed by a type name (not a wildcard _ nor auto)"
5638+
);
5639+
return {};
5640+
}
56315641
a->initializer = std::move(t);
56325642
}
56335643

0 commit comments

Comments
 (0)