Do not repeat the integer conversion that just failed

scan_number_bulk_contiguous() converts an integer token straight from the input
buffer. When the value does not fit, it materializes token_buffer and calls
convert_number(), which tried the very same integer conversion again before
falling back to floating point.

Recording the outcome in number_type skips the second attempt. The resulting
token type and value are unchanged: convert_number() reached the float tail
either way.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MXDi7NTMKAmoArUZSKMc4T
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2026-08-28 14:59:29 +00:00
committed by Claude
co-authored by Claude
parent 2ea1d42995
commit 68d1596427
2 changed files with 8 additions and 2 deletions
+4 -1
View File
@@ -1538,7 +1538,10 @@ scan_number_done:
position.chars_read_current_line += (len - 1);
return integer_result;
}
// the value overflowed: fall through and let the float tail handle it
// The value does not fit an integer, so this token converts as a
// float. Recording that here keeps convert_number() below from
// repeating the integer attempt that just failed.
number_type = token_type::value_float;
}
#endif
+4 -1
View File
@@ -9885,7 +9885,10 @@ scan_number_done:
position.chars_read_current_line += (len - 1);
return integer_result;
}
// the value overflowed: fall through and let the float tail handle it
// The value does not fit an integer, so this token converts as a
// float. Recording that here keeps convert_number() below from
// repeating the integer attempt that just failed.
number_type = token_type::value_float;
}
#endif