Skip to content
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

[SR-11031] bad diagnostics with trailing closure in condition expression #53421

Closed
mattneub opened this issue Jun 27, 2019 · 1 comment
Closed
Labels
compiler The Swift compiler in itself improvement

Comments

@mattneub
Copy link

Previous ID SR-11031
Radar None
Original Reporter @mattneub
Type Improvement
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement
Assignee None
Priority Medium

md5: 6eeab4c046529ed7978dfe12f1f4d85f

duplicates:

  • SR-5869 trailing closure not parsed correctly in if-statement conditional

Issue Description:

This is legal:

let ok = arr.map{$0*2}.first == 4

This is not:

 
if arr.map {$0*2}.first == 4 {
    print("yup")
}

First of all, I think it should be legal. Second, if it isn't legal, we should get better diagnostics. Right now we get

  • Anonymous closure argument not contained in a closure

  • Consecutive statements on a line must be separated by ';'

  • Ambiguous reference to member 'map'

  • Type 'Int' has no member 'first'

  • Closure expression is unused

None of which is very useful.

@mattneub
Copy link
Author

Well it turns out that I reported exactly the same issue with exactly the same code on the duplicate report. Apologies for the noise (it's just that I keep banging into the same problem). If there were a way to delete a report I'd delete this one.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself improvement
Projects
None yet
Development

No branches or pull requests

1 participant