You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
New Swift programmers with a C-like language background or polyglot programmers often find themselves mistakenly using the C-style parameter declaration, e.g.
func cStyle(X x){}
Currently there's a diagnostic emitted for this case:
DiagnosticSpec(message:"expected ':' in parameter", fixIts:["insert ':'"])
Undeniably this is the most unsurprising diagnostic for anyone except for the beginners.
Notwithstanding, when the type is structural,
func cStyleWithStructuralType(Array.Index i){}
As structural types such as Array.Index cannot be identifiers, the parser should not recognize Array.Index as an identifier. However, the diagnostics currently emitted are suboptimal,
DiagnosticSpec(message:"expected ':' and type in parameter", fixIts:["insert ':'"])DiagnosticSpec(message:"unexpected code '.Index i' in parameter clause")
Applying the fix-it "insert ':'" will result in an undesirable outcome,
This issue is also applicable to closure parameters and enum case parameters,
letcStyleWithStructuralType={(Array.Index i) in }case cStyleWithStructuralType(Array.Index i)
We should improve diagnostics for the situations above by emitting diagnostics like these,
DiagnosticSpec(message:"expected ':' in parameter", fixIts:["insert ':'"])DiagnosticSpec(message:"'i' must precede 'Array.Index'", fixIts:["move 'i' in front of 'Array.Index'"])
The text was updated successfully, but these errors were encountered:
Description
New Swift programmers with a C-like language background or polyglot programmers often find themselves mistakenly using the C-style parameter declaration, e.g.
Currently there's a diagnostic emitted for this case:
Undeniably this is the most unsurprising diagnostic for anyone except for the beginners.
Notwithstanding, when the type is structural,
As structural types such as
Array.Index
cannot be identifiers, the parser should not recognizeArray.Index
as an identifier. However, the diagnostics currently emitted are suboptimal,Applying the fix-it
"insert ':'"
will result in an undesirable outcome,This issue is also applicable to closure parameters and enum case parameters,
We should improve diagnostics for the situations above by emitting diagnostics like these,
The text was updated successfully, but these errors were encountered: