Skip to content

Fixes #679: @specialize with invalid attribute #710

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

Merged
merged 3 commits into from
Sep 6, 2022

Conversation

MEnnabah
Copy link
Contributor

@MEnnabah MEnnabah commented Sep 5, 2022

This closes #679.

The solution suggests that the @_specialize parameter is missing a colon (i.e. Expected ':' in attribute argument). This is only true for parameters of SpecializeParameter enum.

However, I believe this behaviour is incorrect in case of supplying a type as a parameter (E.g. @_specialize(T == Int)), because it won't have a colon.

The previous example is from @_specialize attribute pitch, where it seems it's possible to define a parameter with a type only, as opposed to the current unit tests in SwiftParserTest where the type parameters are only defined with a where clause (E.g. @_specialize(where T.Element == Int)).

So I'm not 100% sure about the possibility of supplying the type only without a where clause.

@MEnnabah MEnnabah requested a review from ahoppen as a code owner September 5, 2022 17:01
@@ -573,6 +571,15 @@ extension Parser {
trailingComma: comma,
arena: self.arena
)))
case .none:
let valueLabel = self.consumeAnyToken()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try to parse a trailing comma here just in case the user wrote

@_specialize(e, exported: true)

or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback Robert! I've pushed another commit.

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nitpick, otherwise LGTM.

@CodaFi
Copy link
Contributor

CodaFi commented Sep 6, 2022

@swift-ci test

@CodaFi CodaFi merged commit 72553a2 into swiftlang:main Sep 6, 2022
@MEnnabah MEnnabah deleted the specialize-attribute-invalid-param branch September 7, 2022 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Round-trip failure with @specialize attribute
3 participants