Avatar
func hoge() -> Never { return unsafeBitCast((), to: Never.self) } guard 1 == 0 else { hoge() } print("離脱してないよー")
7:23 AM
Playground execution failed: error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=EXC_I386_GPFLT). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation. * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT) * frame #0: 0x00007fffaba7aa9b libobjc.A.dylib`_objc_msgSend_uncached + 11 frame #1: 0x00007fff9865d231 Foundation`-[NSPlaceholderString initWithString:] + 107 frame #2: 0x000000010c5d4007 PlaygroundLogger`function signature specialization <Arg[0] = Dead> of static PlaygroundLogger.LoggingPolicyStack.get() -> PlaygroundLogger.LoggingPolicyStack + 151 frame #3: 0x000000010c5cdf22 PlaygroundLogger`function signature specialization <Arg[1] = Owned To Guaranteed and Exploded> of playground_log_hidden + 98 frame #4: 0x000000010c5cd65b PlaygroundLogger`playground_log_hidden + 27 frame #5: 0x000000010c5fc094 $__lldb_expr82`hoge() at MyPlayground.playground:2
7:23 AM
コンパイルは通って実行時に死んだ
7:25 AM
unsafeBitCast((), to: Never.self) これでNever型のインスタンス作れるの @Yuta Saito が気づいた