-
Notifications
You must be signed in to change notification settings - Fork 439
Add diagnostic for wrong specialize label #1727
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
e591f32
to
6516f9f
Compare
b104ce1
to
4ddfa36
Compare
4ddfa36
to
343c511
Compare
343c511
to
235f328
Compare
235f328
to
717ac51
Compare
This fixes a couple of formatting issues and resolves the question raised in swiftlang#1727 (comment).
This fixes a couple of formatting issues and resolves the question raised in swiftlang#1727 (comment).
This fixes a couple of formatting issues and resolves the question raised in swiftlang#1727 (comment).
717ac51
to
8af7673
Compare
8af7673
to
f7b4439
Compare
@swift-ci please test |
@swift-ci please test |
7aaaaf3
to
5befba8
Compare
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’d like one more doc comment after reading this with a few days break, otherwise LGTM.
CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparser/ParserTokenSpecSetFile.swift
Show resolved
Hide resolved
5befba8
to
489a750
Compare
8b1159e
to
c06e3cf
Compare
@swift-ci Please test |
c06e3cf
to
9f94aff
Compare
@_specialize(e:) <#declaration#> | ||
@_specialize() <#declaration#>; e |
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.
@ahoppen I did a bit of digging for this issue we breaifly talked about here.
What I can see is, that after calling self.expect(.leftParen)
then the current token is e
we don't consume it, as e
is not a label in @_spacialize(
We then try to find the precedence of the current token. e
is an identifier, thus there are none.
Thats why we get this result I think
testMissingClosingParenToAttribute(): failed - Actual output (+) differed from expected output (-):
–@_specialize(e:) <#declaration#>
+@_specialize() <#declaration#>; e
The parser tries to parse the label e
and don't know it, so we break out if the loop as you suggested.
So I think it's doing its work correctly (for now)
But it would be more nice if we did consume e
as unknown label, and then apply a fixit that suggest to make one if the ones defined in the token set.
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.
Ah, what I missed here is that there is no closing )
in the test case. If the input was @_specialize(e)
(which is what I thought, I just didn’t check carefully), then expect(.rightParen)
would eat the e
as unexpected and recover to )
. So, I agree that the current recovery is consistent and makes sense for now.
Also, this test case is a little degenerate because it doesn’t have a declaration following the attribute. If you make it a little bit more realistic like
@_specialize(e
func foo() {}
then the fixed source is
@_specialize()e
func foo() {}
Putting the e
outside the parentheses makes as much sense as putting it inside, so I think it’s fine and there’s nothing we need to do.
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.
One more comment that I forgot last time, otherwise LGTM. Let’s merge this after 2 months 😉
9f94aff
to
11cffa3
Compare
@swift-ci please test |
@swift-ci please test windows |
Resolves #1605