rumlang / rum

Functional language, easily extensible and possible (Lua features with LISP dialect and functional) to be embarked on software Go!
https://www.rumlang.org/
MIT License
157 stars 13 forks source link

Functions with more than one instuction cause panic #67

Open felipeweb opened 6 years ago

felipeweb commented 6 years ago
› go run main.go
>>> (def f () ((print "first") (print "sec")))
0x1109860
>>> (f)
first
sec
runtime error: Panic[0] - reflect: call of reflect.Value.Call on zero Value
  # triggered at:
    (def f () ((print "first") (print "sec")))
    ----------------------------------------^
  # called from:
    (f)
    --^
  # Interpreter trace:
    goroutine 1 [running]:
    github.com/rumlang/rum/runtime.(*Context).eval.func1.1(0xc4200539b0, 0xc420053980)
        /Users/felipeweb/Code/go/src/github.com/rumlang/rum/runtime/runtime.go:168 +0x90
    panic(0x1131940, 0xc420148a80)
        /usr/local/Cellar/go/1.9.2/libexec/src/runtime/panic.go:491 +0x283
    reflect.flag.mustBe(0x0, 0x13)
        /usr/local/Cellar/go/1.9.2/libexec/src/reflect/value.go:201 +0xc8
    reflect.Value.Call(0x0, 0x0, 0x0, 0xc420148a60, 0x1, 0x1, 0x0, 0x1, 0xc4201a2228)
        /usr/local/Cellar/go/1.9.2/libexec/src/reflect/value.go:300 +0x38
    github.com/rumlang/rum/runtime.(*Context).dispatch(0xc42011c430, 0x1217a20, 0xc420148300, 0xc420053980, 0x7, 0x6f6f6974895d996f, 0x7)
        /Users/felipeweb/Code/go/src/github.com/rumlang/rum/runtime/runtime.go:140 +0x5ea
    github.com/rumlang/rum/runtime.(*Context).eval.func1(0xc4200539b0, 0xc420053980, 0xc420053970, 0xc420053990, 0xc42011c430, 0x1217a20, 0xc420148300)
        /Users/felipeweb/Code/go/src/github.com/rumlang/rum/runtime/runtime.go:171 +0x7d
    github.com/rumlang/rum/runtime.(*Context).eval(0xc42011c430, 0x1217a20, 0xc420148300, 0x7, 0x6030105, 0x7, 0xffffffffffffffff)
        /Users/felipeweb/Code/go/src/github.com/rumlang/rum/runtime/runtime.go:172 +0xeb
    github.com/rumlang/rum/runtime.(*Context).MustEval(0xc42011c430, 0x1217a20, 0xc420148300, 0xc42011c3f0, 0x1)
        /Users/felipeweb/Code/go/src/github.com/rumlang/rum/runtime/runtime.go:203 +0x3f
    github.com/rumlang/rum/runtime.Def.func1(0xc4200104f0, 0xc42011c3f0, 0x0, 0x0, 0xc4201483c0, 0x0)
        /Users/felipeweb/Code/go/src/github.com/rumlang/rum/runtime/runtime.go:337 +0x1b1
    github.com/rumlang/rum/runtime.(*Context).dispatch(0xc4200104f0, 0x1217a20, 0xc420148540, 0xc420053ce8, 0x1217a60, 0xc42017a640, 0x11216e0)
        /Users/felipeweb/Code/go/src/github.com/rumlang/rum/runtime/runtime.go:120 +0x791
    github.com/rumlang/rum/runtime.(*Context).eval.func1(0xc420053d18, 0xc420053ce8, 0xc420053cd8, 0xc420053cf8, 0xc4200104f0, 0x1217a20, 0xc420148540)
        /Users/felipeweb/Code/go/src/github.com/rumlang/rum/runtime/runtime.go:171 +0x7d
    github.com/rumlang/rum/runtime.(*Context).eval(0xc4200104f0, 0x1217a20, 0xc420148540, 0xc4201203f0, 0x1164dd0, 0xc4201186f0, 0xc420120408)
        /Users/felipeweb/Code/go/src/github.com/rumlang/rum/runtime/runtime.go:172 +0xeb
    github.com/rumlang/rum/runtime.(*Context).TryEval(0xc4200104f0, 0x1217a20, 0xc420148540, 0x0, 0x0, 0x0, 0x0)
        /Users/felipeweb/Code/go/src/github.com/rumlang/rum/runtime/runtime.go:197 +0x3f
    github.com/rumlang/rum/interative.REPL(0x0, 0x0)
        /Users/felipeweb/Code/go/src/github.com/rumlang/rum/interative/interative.go:98 +0x456
    main.main()
        /Users/felipeweb/Code/go/src/github.com/rumlang/rum/main.go:25 +0x3c6