[SR-13707] Fix-it for missing let/var in ill-typed expression pattern #56104
Labels
compiler
The Swift compiler in itself
diagnostics QoI
Bug: Diagnostics Quality of Implementation
improvement
type checker
Area → compiler: Semantic analysis
Additional Detail from JIRA
md5: 56d9c5d34022ff4984c7e5bdb640d5e2
relates to:
Issue Description:
Consider this incorrect code:
The programmer (me) thought they were introducing a new binding, `hd` in the Cons case pattern. But, that requires a let/var in the pattern, so the compiler interprets it as an expression pattern. Not to be confused with SR-13706, here `hd` is bound as the name of the function itself, so we get the following type error:
In this case, a fix-it may be warranted to suggest that they add a let/var in the pattern. The errors can get quite nasty and confusing when making this mistake for a more complex enum type, such as in this code:
Which gives all of these errors:
theindigamer (JIRA User) agrees that a fix-it may be good here.
The text was updated successfully, but these errors were encountered: