Skip to content

Commit 41051bd

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

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

source/parse.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5484,6 +5484,13 @@ class parser
54845484
);
54855485
return {};
54865486
}
5487+
if (t->is_wildcard()) {
5488+
errors.emplace_back(
5489+
curr().position(),
5490+
"a 'type ==' alias declaration must be followed by a type name and not a wildcard _"
5491+
);
5492+
return {};
5493+
}
54875494
a->initializer = std::move(t);
54885495
}
54895496

0 commit comments

Comments
 (0)