Closed hachi8833 closed 7 years ago
@hachi8833 Can you also paste stack traces of the panic? Thanks! (This would be helpful so please also paste them in future issues.)
I got it!
Correction: I found the issue above on "enhancement/issue-174-and-issue-194" branch while reviewing. Now I checked this in master branch that the issue persists.
» a = "aa"
#=>
» a.name
Internal Error: interface conversion: vm.Object is *vm.StringObject, not *vm.RClass
panic: interface conversion: vm.Object is *vm.StringObject, not *vm.RClass [recovered]
panic: interface conversion: vm.Object is *vm.StringObject, not *vm.RClass
goroutine 1 [running]:
github.com/goby-lang/goby/vm.(*thread).execInstruction.func1(0xc42012f1a0)
/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/vm/thread.go:71 +0x81
panic(0x1335bc0, 0xc4200169c0)
/usr/local/opt/go/libexec/src/runtime/panic.go:489 +0x2cf
github.com/goby-lang/goby/vm.builtinClassClassMethods.func5.1(0xc42012f1a0, 0x155aa38, 0x0, 0x0, 0x0, 0xc42001a592, 0x4)
/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/vm/class.go:525 +0x9b
github.com/goby-lang/goby/vm.(*thread).evalBuiltInMethod(0xc42012f1a0, 0x1512a80, 0xc42000c400, 0xc4200edce0, 0x0, 0x0, 0x1, 0x0)
/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/vm/thread.go:130 +0x202
github.com/goby-lang/goby/vm.glob..func21(0xc42012f1a0, 0xc42001d880, 0xc42000c560, 0x2, 0x2)
/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/vm/instruction.go:363 +0x397
github.com/goby-lang/goby/vm.(*thread).execInstruction(0xc42012f1a0, 0xc42001d880, 0xc420018c30)
/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/vm/thread.go:75 +0x96
github.com/goby-lang/goby/vm.(*thread).evalCallFrame(0xc42012f1a0, 0xc42001d880)
/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/vm/thread.go:42 +0x60
github.com/goby-lang/goby/vm.(*thread).startFromTopFrame(0xc42012f1a0)
/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/vm/thread.go:36 +0x55
github.com/goby-lang/goby/vm.(*VM).startFromTopFrame(0xc420114120)
/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/vm/vm.go:192 +0x2f
github.com/goby-lang/goby/vm.(*VM).REPLExec(0xc420114120, 0xc42000e040, 0x1, 0x1)
/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/vm/repl.go:43 +0x66a
github.com/goby-lang/goby/igb.StartIgb(0x1397639, 0x5)
/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/igb/repl.go:184 +0xb5d
main.main()
/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/goby.go:27 +0x657
@hachi8833 This is a easy one. It's because String doesn't implement name
method, so the method lookup reached Class#name. And since we don't check type assertion's result and returns right error message (my bad), it just panic.
Closed with PR #282 Merged
Can be reproduced both normal run and REPL.
Looks like
#name
often causes panic on other objects.