-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed as duplicate of#47136
Closed as duplicate of#47136
Copy link
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of ImplementationexpressionsFeature: expressionsFeature: expressionsidentifiersFeature: IdentifiersFeature: Identifiersmissing warningBug: Missing warningBug: Missing warningselfFeature → expressions: The 'self' expressionFeature → expressions: The 'self' expressionswift 5.6type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
| Previous ID | SR-4865 |
| Radar | None |
| Original Reporter | @mattneub |
| Type | Bug |
| Status | Resolved |
| Resolution | Duplicate |
Attachment: Download
Environment
Xcode 8.3.2
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug |
| Assignee | None |
| Priority | Medium |
md5: d3c2dbfe3cffd99ed51448d61dd795be
duplicates:
Issue Description:
This is legal in an instance property declaration:
let listen : UIBarButtonItem = {
let b = UIBarButtonItem(barButtonSystemItem: .play, target: self, action: #selector(doListen))
return b
}()It shouldn't be. There is no self at this point. The code compiles but it isn't going to work, so it shouldn't compile at all.
I see a lot of people on Stack Overflow get caught by this sort of thing, but this is the first time I've made the same mistake myself. The usual context is in configuring a Timer.
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of ImplementationexpressionsFeature: expressionsFeature: expressionsidentifiersFeature: IdentifiersFeature: Identifiersmissing warningBug: Missing warningBug: Missing warningselfFeature → expressions: The 'self' expressionFeature → expressions: The 'self' expressionswift 5.6type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis