Skip to content

Commit 9440687

Browse files
committed
Error instead of crash if users write silly things in aliases.
1 parent 2407a22 commit 9440687

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
outer: type = {
2+
x: requires true == 42;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pure2-bugfix-for-invalid-alias.cpp2...
2+
pure2-bugfix-for-invalid-alias.cpp2(2,25): error: invalid alias declaration - expected 'type', 'namespace', or a type-id after ':'
3+

source/parse.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9835,10 +9835,13 @@ class parser
98359835
a->initializer = std::move(e);
98369836
}
98379837

9838-
// Anything else shouldn't be possible
9838+
// Anything else is illegal
98399839
else {
9840-
assert(false && "ICE: should be unreachable - invalid alias declaration");
9841-
return {};
9840+
errors.emplace_back(
9841+
curr().position(),
9842+
"invalid alias declaration - expected 'type', 'namespace', or a type-id after ':'"
9843+
);
9844+
return {};
98429845
}
98439846

98449847
// And the final ceremonial semicolon

0 commit comments

Comments
 (0)