go-llvm / llgo

LLVM-based compiler for Go
Other
1.26k stars 80 forks source link

Deferring builtin functions makes llgo panic #98

Closed quarnster closed 10 years ago

quarnster commented 11 years ago

Not blocking anything, just something I stumbled upon:

package main

func main() {
    defer println("hello")
}
2013/10/07 00:29:53 building main
panic: unreachable (*types.Builtin), println [recovered]
    panic: /private/tmp/hello.go:3:1: unreachable (*types.Builtin), println [recovered]
    panic: /private/tmp/hello.go:3:1: unreachable (*types.Builtin), println

goroutine 1 [running]:
runtime.panic(0x42b84c0, 0xc2108142a0)
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/panic.c:266 +0xb6
github.com/axw/llgo.func·004()
    /Users/quarnster/code/go/src/github.com/axw/llgo/compiler.go:281 +0x87
runtime.panic(0x42b84c0, 0xc2108142a0)
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/panic.c:248 +0x106
github.com/axw/llgo.func·006()
    /Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:437 +0x2a0
runtime.panic(0x421db40, 0xc2108139d0)
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/panic.c:248 +0x106
github.com/axw/llgo.(*compiler).Resolve(0xc21006b000, 0xc2100525c0, 0xc2100525c0, 0xc2100525c0)
    /Users/quarnster/code/go/src/github.com/axw/llgo/compiler.go:139 +0x81d
github.com/axw/llgo.(*compiler).VisitExpr(0xc21006b000, 0x8910818, 0xc2100525c0, 0xc210045100, 0x421b1a0)
    /Users/quarnster/code/go/src/github.com/axw/llgo/expr.go:568 +0x21e
github.com/axw/llgo.(*compiler).VisitDeferStmt(0xc21006b000, 0xc210044750)
    /Users/quarnster/code/go/src/github.com/axw/llgo/defer.go:138 +0x54
github.com/axw/llgo.(*compiler).VisitStmt(0xc21006b000, 0x89108c0, 0xc210044750)
    /Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:933 +0xa68
github.com/axw/llgo.(*compiler).VisitBlockStmt(0xc21006b000, 0xc21001eb70, 0xc21001eb00)
    /Users/quarnster/code/go/src/github.com/axw/llgo/stmt.go:77 +0x446
github.com/axw/llgo.(*compiler).buildFunction(0xc21006b000, 0xc2102d4440, 0x0, 0x0, 0x0, ...)
    /Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:173 +0xbd2
github.com/axw/llgo.(*compiler).VisitFuncDecl(0xc21006b000, 0xc21001eba0, 0x0, 0x0)
    /Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:226 +0x622
github.com/axw/llgo.(*compiler).VisitDecl(0xc21006b000, 0x89107e0, 0xc21001eba0, 0x0, 0x0)
    /Users/quarnster/code/go/src/github.com/axw/llgo/decl.go:443 +0x2b8
github.com/axw/llgo.(*compiler).Compile(0xc21006b000, 0xc210046f80, 0xc210000198, 0x1, 0x1, ...)
    /Users/quarnster/code/go/src/github.com/axw/llgo/compiler.go:309 +0xab1
main.compileFiles(0x8910738, 0xc21006b000, 0xc21000a070, 0x1, 0x1, ...)
    /Users/quarnster/code/go/src/github.com/axw/llgo/llgo/llgo.go:117 +0x32e
main.main()
    /Users/quarnster/code/go/src/github.com/axw/llgo/llgo/llgo.go:274 +0x3b8

goroutine 3 [syscall]:
runtime.goexit()
    /Users/quarnster/code/3rdparty/go/src/pkg/runtime/proc.c:1396
2013/10/07 00:29:53 exit status 2
axw commented 11 years ago

This will be addressed after #99