Merge 66afb7234cf53957094509014cc5e97fa152b0f4 into d7ae12ae71dfd6ab2997527d295014a8996fa0f9

This commit is contained in:
bptato 2026-03-24 19:53:03 +01:00 committed by GitHub
commit a01c26f153
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 17 deletions

@ -12438,7 +12438,7 @@ static JSValue js_atof(JSContext *ctx, const char *str, const char **pp,
to_digit((uint8_t)p[1]) < radix)) {
p++;
}
if (!(flags & ATOD_INT_ONLY)) {
if (!(flags & ATOD_INT_ONLY) && radix == 10) {
if (*p == '.' && (p > p_start || to_digit((uint8_t)p[1]) < radix)) {
is_float = TRUE;
p++;
@ -12448,9 +12448,7 @@ static JSValue js_atof(JSContext *ctx, const char *str, const char **pp,
(*p == sep && to_digit((uint8_t)p[1]) < radix))
p++;
}
if (p > p_start &&
(((*p == 'e' || *p == 'E') && radix == 10) ||
((*p == 'p' || *p == 'P') && (radix == 2 || radix == 8 || radix == 16)))) {
if (p > p_start && (*p == 'e' || *p == 'E')) {
const char *p1 = p + 1;
is_float = TRUE;
if (*p1 == '+') {
@ -12487,19 +12485,9 @@ static JSValue js_atof(JSContext *ctx, const char *str, const char **pp,
}
buf[j] = '\0';
if (flags & ATOD_ACCEPT_SUFFIX) {
if (*p == 'n') {
p++;
atod_type = ATOD_TYPE_BIG_INT;
} else {
if (is_float && radix != 10)
goto fail;
}
} else {
if (atod_type == ATOD_TYPE_FLOAT64) {
if (is_float && radix != 10)
goto fail;
}
if ((flags & ATOD_ACCEPT_SUFFIX) && *p == 'n') {
p++;
atod_type = ATOD_TYPE_BIG_INT;
}
switch(atod_type) {

@ -664,6 +664,16 @@ function test_global_var_opt()
assert(gvar1, 5);
}
function test_number_literals()
{
assert(0.1.a, undefined);
assert(0x1.a, undefined);
assert(0b1.a, undefined);
assert(01.a, undefined);
assert(0o1.a, undefined);
assert_throws(SyntaxError, () => eval('0.a'));
}
test_op1();
test_cvt();
test_eq();
@ -690,3 +700,4 @@ test_optional_chaining();
test_parse_arrow_function();
test_unicode_ident();
test_global_var_opt();
test_number_literals();