When trying to do operations between a String and an Integer in this specific order Gorilla panics
Example of comparison
[0] >> "abc" == 10
We expect to get false, but instead we get
Gorilla 0.3
[0]>> "abc" == 10
panic: interface conversion: object.Object is *object.Integer, not *object.String
goroutine 1 [running]:
_/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.evalStringInfixExpression(0xc00000a10c, 0x2, 0xaadb20, 0xc000064540, 0xaada00, 0xc0000645a0, 0xc0000645a0, 0xc000064540)
C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:304 +0x5ce
_/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.evalInfixExpression(0xc00000a10c, 0x2, 0xaadb20, 0xc000064540, 0xaada00, 0xc0000645a0, 0xc00003a0c0, 0x0)
C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:252 +0x7c5
_/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.Eval(0xaac840, 0xc00003c0c0, 0xc00002e350, 0xaac840, 0xc00003c0c0)
C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:62 +0xe68
_/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.Eval(0xaac6c0, 0xc00003a080, 0xc00002e350, 0xaac6c0, 0xc00003a080)
C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:37 +0xb38
_/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.evalProgram(0xc000004520, 0xc00002e350, 0x1, 0x0)
C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:123 +0xc9
_/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.Eval(0xaac940, 0xc000004520, 0xc00002e350, 0xc00000a100, 0xb)
C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:34 +0xc5
_/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/repl.Start(0xaac3e0, 0xc000006010, 0xaac400, 0xc000006018)
C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/repl/repl.go:40 +0x36c
_/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/gorilla.RunFile()
C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/gorilla/gorilla.go:23 +0x448
main.main()
C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/main.go:8 +0x27
Example of addition
[0] >> "abc" + 10
We expect to get a RuntimeError like this
Runtime Error:
[Line 1] type mismatch: STRING + INTEGER (When attempting to run 'abc + 10')
But instead the program panics
Gorilla 0.3
[0]>> "abc" + 10
panic: interface conversion: object.Object is *object.Integer, not *object.String
goroutine 1 [running]:
_/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.evalStringInfixExpression(0xc0000a20dc, 0x1, 0xaadb20, 0xc0000b6540, 0xaada00, 0xc0000b65a0, 0xc0000b65a0, 0xc0000b6540)
C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:304 +0x5ce
_/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.evalInfixExpression(0xc0000a20dc, 0x1, 0xaadb20, 0xc0000b6540, 0xaada00, 0xc0000b65a0, 0xc0000d4080, 0x4)
C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:252 +0x7c5
_/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.Eval(0xaac840, 0xc0000d0060, 0xc000088340, 0xaac840, 0xc0000d0060)
C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:62 +0xe68
_/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.Eval(0xaac6c0, 0xc0000d4040, 0xc000088340, 0xaac6c0, 0xc0000d4040)
C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:37 +0xb38
_/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.evalProgram(0xc0000984a0, 0xc000088340, 0x1, 0x0)
C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:123 +0xc9
_/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.Eval(0xaac940, 0xc0000984a0, 0xc000088340, 0xc0000a20d0, 0xa)
C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:34 +0xc5
_/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/repl.Start(0xaac3e0, 0xc0000cc000, 0xaac400, 0xc0000cc008)
C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/repl/repl.go:40 +0x36c
_/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/gorilla.RunFile()
C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/gorilla/gorilla.go:23 +0x448
main.main()
C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/main.go:8 +0x27
The first one is most likely a bug, because comparisons between different type should return true or false, as they do when you put first the Integer and then the String.
Gorilla 0.3
[0]>> 10 == "abc"
false
On the other hand a binary operation between different types can be an error but this one is probably a bug. The reason being that if you try and do the same operation but letting the left expression be an Integer and the right one be a String you indeed get a RuntimeError and the program doesn't panic.
Gorilla 0.3
[0]>> 10 + "abc"
Runtime Error:
[Line 1] type mismatch: INTEGER + STRING (When attempting to run '10 + abc')
All operations except multiplication where the left expression is a String and the right one is an Integer panic. By operations I mean Add (+), Substract (-), Multiply (*), Divide (/), Less Than (<), Greater Than (>), Less Than or Equal (<=), Greater Than or Equal (>=), Equal (==) and Not Equal (!=)