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
jepers opened this issue
Mar 18, 2018
· 5 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
Note that the same issue applies to willSet and set, and that I don't know if the compiler should allow this code or not, only that it shouldn't crash.
// --------------------------------------------------------------------------
// This program compiles with eg the default toolchain of Xcode 9.3 beta 4,
// but crashes recent versions of the compiler (for example dev snapshot
// 2018-02-25, 2018-03-13 and 2018-03-17, have only tested those three).
// --------------------------------------------------------------------------
var a: Int? {
didSet { print("hello") }
}
a? = 123
// --------------------------------------------------------------------------
// Compiling and running with default toolchain of Xcode 9.3 beta 4:
// --------------------------------------------------------------------------
// › swiftc --version
// Apple Swift version 4.1 (swiftlang-902.0.43 clang-902.0.37.1)
// Target: x86_64-apple-darwin17.4.0
// ›
// › swiftc test.swift
// › ./test
// hello
//
// --------------------------------------------------------------------------
// Compiling and running with development snapshot 2018-03-17:
// --------------------------------------------------------------------------
// › /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2018-03-17-a.xctoolchain/usr/bin/swiftc --version
// Apple Swift version 4.2-dev (LLVM cef3fe6d75, Clang bdc970d89c, Swift 931d06d1cc)
// Target: x86_64-apple-darwin17.4.0
// ›
// › /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2018-03-17-a.xctoolchain/usr/bin/swiftc test.swift
// Assertion failed: (value && "No value specified"), function forUnmanaged, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/SILGen/ManagedValue.h, line 91.
// 0 swift 0x000000010aaee2c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
// 1 swift 0x000000010aaee9d6 SignalHandler(int) + 694
// 2 libsystem_platform.dylib 0x00007fff6e86df5a _sigtramp + 26
// ...
Below is an additional demonstration of the same issue. But looking at this program, I think I'm pretty sure that I think it should be valid code, which perhaps means that the above example should be considered valid code too.
(so, just to be very clear, this works as expected for def toolchain of Xc9.3b4 but crashes recent compilers):
var x: Int? = 123 {
willSet {
print("willSet called:")
print(" current value: \(String(describing: x))")
print(" new value: \(String(describing: newValue))")
}
}
print(String(describing: x))
x?.negate()
print(String(describing: x))
The text was updated successfully, but these errors were encountered:
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
Additional Detail from JIRA
md5: 3bae7e3c84e64c7ed6eb3d5392a3be23
Issue Description:
Please see related discussion in this forums thread.
Note that the same issue applies to willSet and set, and that I don't know if the compiler should allow this code or not, only that it shouldn't crash.
Below is an additional demonstration of the same issue. But looking at this program, I think I'm pretty sure that I think it should be valid code, which perhaps means that the above example should be considered valid code too.
(so, just to be very clear, this works as expected for def toolchain of Xc9.3b4 but crashes recent compilers):
The text was updated successfully, but these errors were encountered: