type is modified when float64 has zero value
qazwsxedckll opened this issue · comments
Evilolipop commented
package main
import (
"fmt"
"github.com/dop251/goja"
)
var (
value float64
i interface{}
)
func main() {
value = 0
i = value
vm := goja.New()
o := vm.NewObject()
o.Set("a", i)
fmt.Printf("o.Get(\"a\").ExportType(): %v\n", o.Get("a").ExportType())
}
And I got o.Get("a").ExportType(): int64
Dmitry Panov commented
Not just zero, any number representable as int64 is converted into int64. If you need to preserve the original type, the only option is to use a custom float64 type.