mattn / anko

Scriptable interpreter written in golang
http://play-anko.appspot.com/
MIT License
1.47k stars 118 forks source link

`equal` func in vm/vm.go bug #192

Open chyroc opened 6 years ago

chyroc commented 6 years ago

this is ok in anko,but it should be not ok

{script: `1 == 1.1`, runOutput: true}, // convert 1.1 to 1 , so return true
{script: `1.1 == 1`, runOutput: false}, // convert 1 to 1.0 , so return false(1.1 != 1.0)
MichaelS11 commented 6 years ago

I like to look to Javascript to check on these kind of issues:

a = 1
b = 1.1
console.log(a == b) // false

a = "1"
b = "1.1"
console.log(a == b) // false

a = 1
b = 1.1
console.log(a == b) // false

a = 1
b = "1.1"
console.log(a == b) // false

a = "1"
b = 1.1
console.log(a == b) //false

The Javascript answers look correct to me.

chyroc commented 6 years ago

maybe we can define equalStrict

MichaelS11 commented 6 years ago

Thinking about this more, I think you are correct, we should add ===