Skip to content

Bad diagnostic for generic parameter list on enum case #2273

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

Closed
AnthonyLatsis opened this issue Oct 8, 2023 · 2 comments · Fixed by #2286
Closed

Bad diagnostic for generic parameter list on enum case #2273

AnthonyLatsis opened this issue Oct 8, 2023 · 2 comments · Fixed by #2286
Assignees
Labels
bug Something isn't working good first issue Good for newcomers SwiftParser Bugs in the (new) Parser written in Swift

Comments

@AnthonyLatsis
Copy link
Contributor

AnthonyLatsis commented Oct 8, 2023

Issue Kind

Bad Diagnostic Produced

Source Code

enum Foo {
    case bar<T>(baz: T)
}
/Users/mac/Desktop/test.swift:106:13: error: consecutive declarations on a line must be separated by newline or ';' [bridged_error]
    case bar<T>(baz: T)
            ^
/Users/mac/Desktop/test.swift:106:13: note: insert newline [bridged_note]
    case bar<T>(baz: T)
            ^
/Users/mac/Desktop/test.swift:106:13: note: insert ';' [bridged_note]
    case bar<T>(baz: T)
            ^
            ;
/Users/mac/Desktop/test.swift:106:13: error: expected 'func' in function [bridged_error]
    case bar<T>(baz: T)
            ^
/Users/mac/Desktop/test.swift:106:13: note: insert 'func' [bridged_note]
    case bar<T>(baz: T)
            ^
            func 
/Users/mac/Desktop/test.swift:106:14: error: unexpected code 'T>' before parameter clause [bridged_error]
    case bar<T>(baz: T)

Description

Twin of swiftlang/swift#69036.

@AnthonyLatsis AnthonyLatsis added bug Something isn't working SwiftParser Bugs in the (new) Parser written in Swift labels Oct 8, 2023
@ahoppen
Copy link
Member

ahoppen commented Oct 8, 2023

Tracked in Apple’s issue tracker as rdar://116651710

@ahoppen ahoppen added the good first issue Good for newcomers label Oct 9, 2023
@ahoppen
Copy link
Member

ahoppen commented Oct 9, 2023

This should be fairly easy to fix by calling into parseGenericParameters and marking the result as unexpected if we are at a < after parsing the enum case’s name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers SwiftParser Bugs in the (new) Parser written in Swift
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants