Comparing external function does not work
rhysd opened this issue · 0 comments
rhysd commented
Repro:
let rec f _ = () in
f true;
println_bool true;
println_bool (println_bool = f)
Error:
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x56a57ee]
runtime stack:
runtime.throw(0x590c4f4, 0x2a)
/usr/local/Cellar/go/1.8/libexec/src/runtime/panic.go:596 +0x95
runtime.sigpanic()
/usr/local/Cellar/go/1.8/libexec/src/runtime/signal_unix.go:274 +0x2db
goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x4100a60, 0xc420097360, 0x590c233)
/usr/local/Cellar/go/1.8/libexec/src/runtime/cgocall.go:131 +0xe2 fp=0xc420097320 sp=0xc4200972e0
llvm.org/llvm/bindings/go/llvm._Cfunc_LLVMBuildExtractValue(0x6f00b70, 0x6b08f28, 0x0, 0x6b08a20, 0x0)
llvm.org/llvm/bindings/go/llvm/_obj/_cgo_gotypes.go:1572 +0x4e fp=0xc420097360 sp=0xc420097320
llvm.org/llvm/bindings/go/llvm.Builder.CreateExtractValue.func2(0x6f00b70, 0x6b08f28, 0x0, 0x6b08a20, 0xc420000340)
/Users/rhayasd/.go/src/llvm.org/llvm/bindings/go/llvm/ir.go:1722 +0xb5 fp=0xc420097398 sp=0xc420097360
llvm.org/llvm/bindings/go/llvm.Builder.CreateExtractValue(0x6f00b70, 0x6b08f28, 0x0, 0x0, 0x0, 0x0)
/Users/rhayasd/.go/src/llvm.org/llvm/bindings/go/llvm/ir.go:1722 +0x98 fp=0xc4200973d8 sp=0xc420097398
github.com/rhysd/gocaml/codegen.(*blockBuilder).buildEq(0xc42000c5c0, 0x635ac80, 0xc420016660, 0x100000020, 0x6b08f28, 0x6b08cb8, 0x590510c, 0x3, 0xc4200184b0)
/Users/rhayasd/.go/src/github.com/rhysd/gocaml/codegen/block_builder.go:111 +0x527 fp=0xc4200974e0 sp=0xc4200973d8
github.com/rhysd/gocaml/codegen.(*blockBuilder).buildVal(0xc42000c5c0, 0xc420018770, 0x4, 0x635a840, 0xc420016750, 0x6b08f28)
/Users/rhayasd/.go/src/github.com/rhysd/gocaml/codegen/block_builder.go:198 +0x27c6 fp=0xc4200978f8 sp=0xc4200974e0
github.com/rhysd/gocaml/codegen.(*blockBuilder).buildInsn(0xc42000c5c0, 0xc420014640, 0x6b08f28)
/Users/rhayasd/.go/src/github.com/rhysd/gocaml/codegen/block_builder.go:412 +0x67 fp=0xc420097940 sp=0xc4200978f8
github.com/rhysd/gocaml/codegen.(*blockBuilder).buildBlock(0xc42000c5c0, 0xc42000c500, 0x63d3f40)
/Users/rhayasd/.go/src/github.com/rhysd/gocaml/codegen/block_builder.go:420 +0x41 fp=0xc420097970 sp=0xc420097940
github.com/rhysd/gocaml/codegen.(*moduleBuilder).buildMain(0xc420068180, 0xc42000c500)
/Users/rhayasd/.go/src/github.com/rhysd/gocaml/codegen/module_builder.go:274 +0x2ca fp=0xc4200979e8 sp=0xc420097970
github.com/rhysd/gocaml/codegen.(*moduleBuilder).build(0xc420068180, 0xc42000c560, 0x2, 0x0)
/Users/rhayasd/.go/src/github.com/rhysd/gocaml/codegen/module_builder.go:327 +0x4f2 fp=0xc420097c80 sp=0xc4200979e8
github.com/rhysd/gocaml/codegen.NewEmitter(0xc42000c560, 0xc420018570, 0xc420016330, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/Users/rhayasd/.go/src/github.com/rhysd/gocaml/codegen/emitter.go:161 +0xc4 fp=0xc420097d28 sp=0xc420097c80
github.com/rhysd/gocaml/compiler.(*Compiler).emitterFromSource(0xc420097f48, 0xc420016330, 0x0, 0x4f, 0x24f)
/Users/rhayasd/.go/src/github.com/rhysd/gocaml/compiler/compiler.go:139 +0x10e fp=0xc420097dc8 sp=0xc420097d28
github.com/rhysd/gocaml/compiler.(*Compiler).Compile(0xc420055f48, 0xc420016330, 0x0, 0x0)
/Users/rhayasd/.go/src/github.com/rhysd/gocaml/compiler/compiler.go:180 +0x4b fp=0xc420097e10 sp=0xc420097dc8
main.main()
/Users/rhayasd/.go/src/github.com/rhysd/gocaml/main.go:125 +0x26f fp=0xc420097f88 sp=0xc420097e10
runtime.main()
/usr/local/Cellar/go/1.8/libexec/src/runtime/proc.go:185 +0x20a fp=0xc420097fe0 sp=0xc420097f88
runtime.goexit()
/usr/local/Cellar/go/1.8/libexec/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc420097fe8 sp=0xc420097fe0
goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/usr/local/Cellar/go/1.8/libexec/src/runtime/asm_amd64.s:2197 +0x1
Panic at code generation.