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-6157] Trailing closure for subscript in statement condition should be diagnosed #48712

Open
rintaro mannequin opened this issue Oct 16, 2017 · 1 comment
Open

[SR-6157] Trailing closure for subscript in statement condition should be diagnosed #48712

rintaro mannequin opened this issue Oct 16, 2017 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@rintaro
Copy link
Mannequin

rintaro mannequin commented Oct 16, 2017

Previous ID SR-6157
Radar None
Original Reporter @rintaro
Type Bug
Environment

Apple Swift version 4.0.1 (swiftlang-900.0.68 clang-900.0.38)
Target: x86_64-apple-macosx10.9

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 1f5530fb7e498efb3b36d8985f299fab

Issue Description:

This compiles without error.

struct X {
  subscript(x: () -> Int) -> Bool { return true }
}
let x = X();
if x[] { 1 } { }

Trailing closures in statement condition should be diagnosed.

@belkadan
Copy link
Contributor

Oof. I'm not sure we should even be allowing trailing closures on subscripts in the first place, but it's certainly a bug to allow them in conditions when it's banned for functions and initializers.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

1 participant