fallthrough
case 'i', 'I':
n := commonPrefixLenIgnoreCase(s, "infinity")
- // both "inf" and "infinity" are ok
+ // Anything longer than "inf" is ok, but if we
+ // don't have "infinity", only consume "inf".
+ if 3 < n && n < 8 {
+ n = 3
+ }
if n == 3 || n == 8 {
return math.Inf(sign), nsign + n, true
}
continue
}
// Adding characters that do not extend a number should not invalidate it.
- // Test a few.
- for _, suffix := range []string{" ", "q", "+", "-", "<", "=", ">", "(", ")"} {
+ // Test a few. The "i" and "init" cases test that we accept "infi", "infinit"
+ // correctly as "inf" with suffix.
+ for _, suffix := range []string{" ", "q", "+", "-", "<", "=", ">", "(", ")", "i", "init"} {
in := test.in + suffix
_, n, err := ParseFloatPrefix(in, 64)
if err != nil {