swiftlang/swift-syntax

Bad diagnostic for generic parameter list on enum case

Closed this issue · 2 comments

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.

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

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.