js-on-sx: js-num-to-int guards NaN/Infinity → 0 (+2 String)
Spec ToUint16 (String.fromCharCode argument coercion) maps non-finite values to 0. We had bare (floor v) which left inf/-inf/nan through, breaking: String.fromCharCode(Infinity).charCodeAt(0) === 0 // was "" → err String.fromCharCode(NaN).charCodeAt(0) === 0 // was "" → err Add NaN/inf/-inf guards returning 0 before the floor+signed-flip path. Unit 521/522, slice 148/148 unchanged. String 38/100 → 40/100 (+2: fromCharCode/S9.7_A1, S9.7_A2.1).
This commit is contained in:
@@ -2291,8 +2291,13 @@
|
||||
(fn
|
||||
(v)
|
||||
(let
|
||||
((n (if (number? v) v (js-to-number v))))
|
||||
(if (>= n 0) (floor n) (- 0 (floor (- 0 n)))))))
|
||||
((n (js-to-number v)))
|
||||
(cond
|
||||
((js-number-is-nan n) 0)
|
||||
((= n (js-infinity-value)) 0)
|
||||
((= n (- 0 (js-infinity-value))) 0)
|
||||
((>= n 0) (floor n))
|
||||
(else (- 0 (floor (- 0 n))))))))
|
||||
|
||||
(define dict-has? (fn (d k) (contains? (keys d) k)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user