diff --git a/compiler/natives/src/strconv/atoi.go b/compiler/natives/src/strconv/atoi.go index 63ea9b732..ce8790478 100644 --- a/compiler/natives/src/strconv/atoi.go +++ b/compiler/natives/src/strconv/atoi.go @@ -12,6 +12,15 @@ const ( minInt32 float64 = -1 << 31 ) +//gopherjs:keep-original +func ParseInt(s string, base, bitSize int) (i int64, err error) { + if base == 10 && (bitSize == 0 || bitSize == 32) { + i, err := Atoi(s) + return int64(i), err + } + return _gopherjs_original_ParseInt(s, base, bitSize) +} + // Atoi returns the result of ParseInt(s, 10, 0) converted to type int. func Atoi(s string) (int, error) { const fnAtoi = "Atoi" @@ -39,7 +48,8 @@ func Atoi(s string) (int, error) { floatval := jsValue.Float() if floatval > maxInt32 { return int(maxInt32), rangeError(fnAtoi, s) - } else if floatval < minInt32 { + } + if floatval < minInt32 { return int(minInt32), rangeError(fnAtoi, s) } // Success!