-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
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.
Description
| Previous ID | SR-14133 |
| Radar | None |
| Original Reporter | JaydenIrwin (JIRA User) |
| Type | Bug |
Environment
Xcode 11.2 on macOS 11.1
Additional Detail from JIRA
| Votes | 0 |
| Component/s | |
| Labels | Bug |
| Assignee | None |
| Priority | Medium |
md5: 6f493812816ae17f68490d6e1f1e8cb0
Issue Description:
I am getting some incorrect code diagnostics. The error: "Variable being used before being initialization" appears on the lines labeled below.
struct MyButton<Label: View>: View {
@State var label: Label
@State var action: () -> Void
var body: some View {...}
init(action: @escaping () -> Void, @ViewBuilder label: () -> Label) {
self.label = label() //Variable being used before being initialization
self.action = action //Variable being used before being initialization
}
}
extension MyButton where Label == Text {
init<S>(_ title: S, action: @escaping () -> Void) where S : StringProtocol {
self.label = Text(title) //Variable being used before being initialization
self.action = action //Variable being used before being initialization
}
}I know this is wrong because if I remove the extension code, all 4 of the errors go away (even the ones not in the extension!).
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.