Example file does not compile
djtech42 opened this issue · comments
Dan Turner commented
test.swift:
#!/usr/bin/swift sh
import PromiseKit // @mxcl ~> 6.5
firstly {
after(.seconds(2))
}.then {
after(.milliseconds(500))
}.done {
print("notice: two and a half seconds elapsed")
exit(0)
}
RunLoop.main.run()
After running chmod +x test.swift
, running it with ./test.swift
results in these errors:
Compile Swift Module 'test' (1 sources)
/Users/dan/Library/Developer/swift-sh.cache/test/main.swift:10:5: error: use of unresolved identifier 'exit'
exit(0)
^~~~
/Users/dan/Library/Developer/swift-sh.cache/test/main.swift:13:1: error: use of unresolved identifier 'RunLoop'
RunLoop.main.run()
^~~~~~~
error: terminated(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/dan/Library/Developer/swift-sh.cache/test/.build/debug.yaml test.exe output:
Compile Swift Module 'test' (1 sources)
/Users/dan/Library/Developer/swift-sh.cache/test/main.swift:10:5: error: use of unresolved identifier 'exit'
exit(0)
^~~~
/Users/dan/Library/Developer/swift-sh.cache/test/main.swift:13:1: error: use of unresolved identifier 'RunLoop'
RunLoop.main.run()
^~~~~~~
Fatal error: Error raised at top level: (extension in Shwifty):__C.NSTask.ExecutionError(stdout: (extension in Shwifty):__C.NSTask.Output, stderr: (extension in Shwifty):__C.NSTask.Output, status: 1, arg0: "/usr/bin/swift", args: ["run"]): file /BuildRoot/Library/Caches/com.apple.xbs/Sources/swiftlang_Fall2018/swiftlang_Fall2018-1000.11.42/src/swift/stdlib/public/core/ErrorType.swift, line 191
fish: './test.swift' terminated by signal SIGILL (Illegal instruction)
Dan Turner commented
I fixed it by adding
import Foundation
Dan Turner commented
fixed with #19