Skip to content

Commit 344aadf

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 3b021d7 commit 344aadf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/SwiftParser/Types.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,10 @@ extension Parser.Lookahead {
783783

784784
mutating func canParseTupleBodyType() -> Bool {
785785
guard
786-
!self.at(.rightParen, .rightBrace) && !self.atContextualPunctuator("...") && !self.atStartOfDeclaration()
786+
!self.at(.rightParen, .rightBrace) && !self.atContextualPunctuator("...") &&
787+
// In types, we do not allow for an inout binding to be declared in a
788+
// tuple type.
789+
(self.at(.keyword(.inout)) || !self.atStartOfDeclaration())
787790
else {
788791
return self.consume(if: .rightParen) != nil
789792
}

0 commit comments

Comments
 (0)