-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Closed
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 itselfexpressionsFeature: expressionsFeature: expressionsforce-valueFeature → expressions: Force-value aka force-unwrap expressionFeature → expressions: Force-value aka force-unwrap expressionimplicit member expressionsFeature → expressions: Implicit member expressionsFeature → expressions: Implicit member expressionsswift 5.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysisunexpected errorBug: Unexpected errorBug: Unexpected error
Description
Previous ID | SR-10569 |
Radar | None |
Original Reporter | @YOCKOW |
Type | Bug |
Environment
Swift: swift-DEVELOPMENT-SNAPSHOT-2019-04-16-a
OS: macOS mojave 10.14.4
Additional Detail from JIRA
Votes | 1 |
Component/s | Compiler |
Labels | Bug, DiagnosticsQoI |
Assignee | None |
Priority | Medium |
md5: dab68829c010ec40062a551a4d76d0c6
relates to:
Issue Description:
Code:
struct S {
init?(_ string: String) {}
}
let s: S = .init("Failable")!
Result:
dot+forceunwrap.swift:4:13: error: value of optional type 'S?' must be unwrapped to a value of type 'S'
let s: S = .init("Failable")!
^
dot+forceunwrap.swift:4:13: note: coalesce using '??' to provide a default when the optional value contains 'nil'
let s: S = .init("Failable")!
^
( ?? <#default value#>)
dot+forceunwrap.swift:4:13: note: force-unwrap using '!' to abort execution if the optional value contains 'nil'
let s: S = .init("Failable")!
^
!
dot+forceunwrap.swift:4:29: error: cannot force unwrap value of non-optional type 'S'
let s: S = .init("Failable")!
~~~~~~~~~~~~~~~~~^
Expected Behavior:
Meaningful fixit is viewed.
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 itselfexpressionsFeature: expressionsFeature: expressionsforce-valueFeature → expressions: Force-value aka force-unwrap expressionFeature → expressions: Force-value aka force-unwrap expressionimplicit member expressionsFeature → expressions: Implicit member expressionsFeature → expressions: Implicit member expressionsswift 5.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysisunexpected errorBug: Unexpected errorBug: Unexpected error