diff --git a/builtins.go b/builtins.go index 33719b6..43ed841 100644 --- a/builtins.go +++ b/builtins.go @@ -478,15 +478,15 @@ var builtinExponent = liftNumeric(func(f float64) float64 { func liftBitwise(f func(int64, int64) int64) func(*evaluator, potentialValue, potentialValue) (value, error) { return func(e *evaluator, xp, yp potentialValue) (value, error) { - x, err := e.evaluateInt64(xp) + x, err := e.evaluateNumber(xp) if err != nil { return nil, err } - y, err := e.evaluateInt64(yp) + y, err := e.evaluateNumber(yp) if err != nil { return nil, err } - return makeDoubleCheck(e, float64(f(x, y))) + return makeDoubleCheck(e, float64(f(int64(x.value), int64(y.value)))) } } diff --git a/evaluator.go b/evaluator.go index 5409a85..f3141a8 100644 --- a/evaluator.go +++ b/evaluator.go @@ -110,8 +110,6 @@ func (e *evaluator) getInt64(val value) (int64, error) { if err != nil { return 0, err } - // We conservatively convert ot int32, so that it can be machine-sized int - // on any machine. And it's used only for indexing anyway. intNum := int64(num.value) if float64(intNum) != num.value { return 0, e.Error(fmt.Sprintf("Expected an integer, but got %v", num.value)) diff --git a/testdata/bitwise_and3.golden b/testdata/bitwise_and3.golden index 836e54d..573541a 100644 --- a/testdata/bitwise_and3.golden +++ b/testdata/bitwise_and3.golden @@ -1,10 +1 @@ -RUNTIME ERROR: Expected an integer, but got 1e+30 -------------------------------------------------- - testdata/bitwise_and3:1:1-10 $ - -1e30 & 42 - -------------------------------------------------- - During evaluation - - +0