js-on-sx: parseFloat/parseInt return NaN for digitless prefix
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 26s

This commit is contained in:
2026-05-09 03:42:47 +00:00
parent a6793fa656
commit 141795449a
2 changed files with 13 additions and 0 deletions

View File

@@ -4523,8 +4523,19 @@
((end (js-float-prefix-end s 0 false false false)))
(cond
((= end 0) (js-nan-value))
((not (js-str-has-digit? s 0 end)) (js-nan-value))
(else (js-parse-num-safe (js-string-slice s 0 end)))))))))
(define
js-str-has-digit?
(fn
(s i n)
(cond
((>= i n) false)
((let ((c (char-at s i))) (and (>= (char-code c) 48) (<= (char-code c) 57)))
true)
(else (js-str-has-digit? s (+ i 1) n)))))
(define
js-float-has-infinity-prefix?
(fn