js-on-sx: NaN / Infinity resolve at transpile; strict-eq returns false for NaN
Previously NaN / Infinity were SX symbols that couldn't be (define)'d because the SX tokenizer parses 'NaN' and 'Infinity' as numeric literals. js-transpile-ident now rewrites NaN -> (js-nan-value), Infinity -> (js-infinity-value), each a zero-arg function returning the appropriate IEEE value ((/ 0.0 0.0) and (/ 1.0 0.0)). Also fixes js-number-is-nan: in this SX, (= nan nan) returns true, so the classic 'v !== v' trick doesn't work. Now checks (inspect v) against 'nan'/'-nan' strings. Extends js-strict-eq: NaN === NaN returns false per ES spec. 8 new unit tests, 497/499 total. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -157,6 +157,8 @@
|
||||
(name)
|
||||
(cond
|
||||
((= name "undefined") (list (js-sym "quote") :js-undefined))
|
||||
((= name "NaN") (list (js-sym "js-nan-value")))
|
||||
((= name "Infinity") (list (js-sym "js-infinity-value")))
|
||||
(else (js-sym name)))))
|
||||
|
||||
;; ── Unary ops ─────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user