为什么我的Swift代码在比较大小写时会爆炸?

时间:2016-12-23 15:29:42

标签: swift ibm-cloud

我实际上是在学习swift,我正在测试开关控制流程。我在IBM Swift Sandbox上试用了这段代码:

let const = "Z"

switch const {

case "a" ,
     "A": print("La primera letra del abecedario")
case "z": print("La ultima letra del abecedario")
default:  print("NPI de que letra se trate")

}

一切正常,用const = {“a”,“A”,“f”,“z”}进行测试。但是当const为“Z”时,我会得到error

terminate called after throwing an instance of 'std::system_error'
  what():  Resource temporarily unavailable
0  swift-build-tool 0x000000000050bade llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 46
1  swift-build-tool 0x000000000050ca49
2  swift-build-tool 0x000000000050cd53
3  libpthread.so.0  0x00007f960ca22330
4  libc.so.6        0x00007f960bc5fc37 gsignal + 55
5  libc.so.6        0x00007f960bc63028 abort + 328
6  libstdc++.so.6   0x00007f960c56a535 __gnu_cxx::__verbose_terminate_handler() + 341
7  libstdc++.so.6   0x00007f960c5686d6
8  libstdc++.so.6   0x00007f960c568703
9  libstdc++.so.6   0x00007f960c568922
10 libstdc++.so.6   0x00007f960c5ba800 std::__throw_system_error(int) + 128
11 libstdc++.so.6   0x00007f960c5bbd68 std::thread::_M_start_thread(std::shared_ptr<std::thread::_Impl_base>) + 584
12 swift-build-tool 0x0000000000494d6d
13 swift-build-tool 0x0000000000494b0d
14 swift-build-tool 0x0000000000494a01 llbuild::buildsystem::createLaneBasedExecutionQueue(llbuild::buildsystem::BuildExecutionQueueDelegate&, int) + 49
15 swift-build-tool 0x0000000000490ba8 llbuild::buildsystem::BuildSystemFrontendDelegate::createExecutionQueue() + 264
16 swift-build-tool 0x00000000004b98e9
17 swift-build-tool 0x00000000004b9823 llbuild::buildsystem::BuildSystem::build(llvm::StringRef) + 67
18 swift-build-tool 0x000000000049150d llbuild::buildsystem::BuildSystemFrontend::build(llvm::StringRef) + 1405
19 swift-build-tool 0x000000000048e086
20 swift-build-tool 0x000000000048dc7a main + 170
21 libc.so.6        0x00007f960bc4af45 __libc_start_main + 245
22 swift-build-tool 0x000000000048db04
swift-build: error: Child process exited with signal

1 个答案:

答案 0 :(得分:0)

现在在Sandbox中试用您的代码,看起来它与const = "Z"的效果很好。这是Sandbox端的一个错误,它看起来像。我们在假日期间遇到了一些服务器问题,我们正在努力解决这些问题。你的代码似乎是正确的。