You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-10931 Optional initialization inconsistent between Optional vs T?
Issue Description:
Given the following class:
classFoo {
varbar: (String?, String?)
}
I expect it not to compile, considering bar is a non-optional type without a default value. Instead, it compiles and the synthesized initializer sets bar to (nil, nil):
letf = Foo()
f.bar// => (nil, nil)
If the tuple is instead a constant, it does not compile:
Additional Detail from JIRA
md5: 5b5256f99ab266dee19af877b39508b3
relates to:
Issue Description:
Given the following class:
I expect it not to compile, considering
bar
is a non-optional type without a default value. Instead, it compiles and the synthesized initializer setsbar
to(nil, nil)
:If the tuple is instead a constant, it does not compile:
This results in:
Further, the messaging is not consistent, as non-tuple types communicate more information in the compiler error. With a string:
the following additional error is communicated:
While that is the stored property usage, similar behavior results in normal variable usage.
But with a constant:
It does not compile:
If this behavior is expected, I do not see it documented in the language guide.
The text was updated successfully, but these errors were encountered: