Skip to content

Commit 1459d25

Browse files
committed
[reference-binding] Fix an ambiguity when parsing inout in function types.
This was exposed by: decl/enum/enumtest.swift The problem here is that we are now allowing for inout to be the start of a swift decl. This means that if one defines an enum case with a inout parameter, the parser gets confused and doesnt think it is part of the type. I worked around this by changing canParseTupleTypeBody to say that an inout binding cannot be parsed as part of a tuple type. This fits already with how we want to model this.
1 parent c97121d commit 1459d25

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/Parse/ParseType.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,10 @@ bool Parser::canParseOldStyleProtocolComposition() {
16761676

16771677
bool Parser::canParseTypeTupleBody() {
16781678
if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::r_brace) &&
1679-
Tok.isNotEllipsis() && !isStartOfSwiftDecl()) {
1679+
Tok.isNotEllipsis() &&
1680+
// In types, we do not allow for an inout binding to be declared in a
1681+
// tuple type.
1682+
(Tok.is(tok::kw_inout) || !isStartOfSwiftDecl())) {
16801683
do {
16811684
// The contextual inout marker is part of argument lists.
16821685
consumeIf(tok::kw_inout);

0 commit comments

Comments
 (0)