Skip to content

Commit 47b61d4

Browse files
committed
[Parser] complain for invalid enum raw value
Instead of fail silently, issue a diagosis when a valid expression can not be parsed for enum raw value. This resolves [SR-510](https://bugs.swift.org/browse/SR-510).
1 parent 2187929 commit 47b61d4

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,8 @@ ERROR(throw_in_function_type,type_parsing,none,
584584
// Enum Types
585585
ERROR(expected_expr_enum_case_raw_value,type_parsing,PointsToFirstBadToken,
586586
"expected expression after '=' in 'case'", ())
587+
ERROR(not_a_proper_raw_value_expression,type_parsing,none,
588+
"not a proper raw value expression", ())
587589
ERROR(nonliteral_enum_case_raw_value,type_parsing,PointsToFirstBadToken,
588590
"raw value for enum case must be a literal", ())
589591

lib/Parse/ParseDecl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4404,6 +4404,7 @@ ParserStatus Parser::parseDeclEnumCase(ParseDeclOptions Flags,
44044404
return Status;
44054405
}
44064406
if (RawValueExpr.isNull()) {
4407+
diagnose(EqualsLoc, diag::not_a_proper_raw_value_expression);
44074408
Status.setIsParseError();
44084409
return Status;
44094410
}

0 commit comments

Comments
 (0)