-
Notifications
You must be signed in to change notification settings - Fork 439
Fix a crash in diagnostic generation if a primary associated type is not ended with a >
#1110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This allows us to reduce cases in which the parser is crashing during diagnostic generation.
@swift-ci Please test |
@@ -258,7 +258,12 @@ extension Parser { | |||
arena: self.arena)) | |||
} while keepGoing != nil && loopProgress.evaluate(currentToken) | |||
} | |||
let rangle = self.consumeAnyToken(remapping: .rightAngle) | |||
let rangle: RawTokenSyntax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the precedence of :
compared to >
? Could we use expect
here instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think we currently have a way to expect
the >
as a token prefix. The problem here is that sometimes the >
can be part of a bigger token.
DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in protocol"), | ||
DiagnosticSpec(locationMarker: "2️⃣", message: "expected name in primary associated type clause"), | ||
DiagnosticSpec(locationMarker: "2️⃣", message: "expected '>' to end primary associated type clause"), | ||
DiagnosticSpec(locationMarker: "3️⃣", message: "expected type in type"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to my PR - expected type in type
is uh... not great 😅. I'm fine if you just want to add a TODO here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW I think I would just not expect this particular diagnostic, the rest seem fine. If we ate the :
we'd get an "unexpected :" instead which might make more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I adjusted a name and now it’s expected type in inherited type
. I think that makes sense.
…not ended with a `>` In the new test case, we were parsing `:` as a right angle, which caused a crash when we were retrieving the token’s kind in diagnostic generation.
5a069e8
to
9dc574b
Compare
@swift-ci Please test |
In the new test case, we were parsing
:
as a right angle, which caused a crash when we were retrieving the token’s kind in diagnostic generation.