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
swift-ci opened this issue
Jul 10, 2018
· 4 comments
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfcrashBug: A crash, i.e., an abnormal termination of software
infixoperator ??=
func ??= <T>(lhs: inoutT?, rhs: T?) {
print(lhsasAny)
}
prefixoperator ~~
prefixfunc ~~ <T>(foo: inoutT?) {
print(fooasAny)
}
vara: Int?
a ??= 5// OK
~~a// OKvarb: Int!
b ??= 5// Binary operator '??=' cannot be applied to operands of type 'Int!' and 'Int'
~~b// Cannot convert value of type 'Int!' to expected argument type 'inout _?'varc: Int = 0c ??= 5// Binary operator '??=' cannot be applied to two 'Int' operands
~~c// Cannot convert value of type 'Int' to expected argument type 'inout _?'
In general, IUOs & non-Optionals are magically transformed into Optionals, so it feels odd that it doesn't happen here. Inout Optional parameters on regular (i.e., non-operator) functions seem to work.
Apologies if this has already been filed elsewhere; I couldn't really figure out how to search for this problem.
The text was updated successfully, but these errors were encountered:
The first part seems to be fixed in Swift 4.2 (not surprising, given the changes in the IUO implementation). The second part is correct behavior, since the implementation of, say, ??= could be to just assign nil to the inout parameter.
…except that with an asserts build I'm seeing a crash on the second example, and we should definitely fix that!
Assertion failed: (toIO->getObjectType()->isEqual(fromLValue->getObjectType())), function coerceToType, file /Volumes/Data/swift-public/swift/lib/Sema/CSApply.cpp, line 6776.
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfcrashBug: A crash, i.e., an abnormal termination of software
Environment
macOS 10.13.4
Xcode 9.4.1 (9F2000) with built-in Swift
Additional Detail from JIRA
md5: 533e53fc2a529490ce7fb5754e8bc9c1
Issue Description:
In general, IUOs & non-Optionals are magically transformed into Optionals, so it feels odd that it doesn't happen here. Inout Optional parameters on regular (i.e., non-operator) functions seem to work.
Apologies if this has already been filed elsewhere; I couldn't really figure out how to search for this problem.
The text was updated successfully, but these errors were encountered: