12 Commits

Author SHA1 Message Date
97180b4aa3 js-on-sx: wrapper constructor-detection, Array.prototype.toString, >>> operator
Some checks are pending
Test, Build, and Deploy / test-build-deploy (push) Waiting to run
Number.__callable__ and String.__callable__ now check this.__proto__ ===
Number/String.prototype before writing wrapper slots, preventing false-positive
mutation when called as plain function. js-to-number extended to unwrap
wrapper dicts and call valueOf/toString for plain objects. Array.prototype.toString
replaced with a direct js-list-join implementation (eliminates infinite recursion
via js-invoke-method on dict-based arrays). >>> added to transpiler + runtime.

String test262 subset: 62→66/100. 529/530 unit, 147/148 slice.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 19:22:53 +00:00
ea63b6d9bb plans: log precision number-to-string iteration
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 14:42:44 +00:00
5d7f931cf1 js-on-sx: high-precision number-to-string via round-trip + digit extraction
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
- js-big-int-str-loop: extract decimal digits from integer-valued float
- js-find-decimal-k: find min decimal places k where round(n*10^k)/10^k == n
- js-format-decimal-digits: insert decimal point into digit string at position (len-k)
- js-number-to-string: if 6-sig-fig round-trip fails AND n in [1e-6, 1e21),
  use digit extraction for full precision (up to 17 sig figs)
- String(1.0000001)="1.0000001", String(1/3)="0.3333333333333333"
- String test262 subset: 58→62/100

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 14:42:32 +00:00
79f3e1ada2 plans: log String wrapper + number-to-string sci notation iteration
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 14:27:25 +00:00
4d00250233 js-on-sx: String wrapper objects + number-to-string sci notation expansion
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
- js-to-string: return __js_string_value__ for String wrapper dicts
- js-loose-eq: coerce String wrapper objects to primitive before compare
- String.__callable__: set __js_string_value__ + length on 'this' when called as constructor
- js-expand-sci-notation: new helper converts mantissa+exp to decimal or integer form
- js-number-to-string: expand 1e-06→0.000001, 1e+06→1000000; fix 1e+21 (was 1e21)
- String test262 subset: 45→58/100

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 14:27:13 +00:00
80c21cbabb js-on-sx: String fixes — fromCodePoint, multi-arg indexOf/split/lastIndexOf, matchAll, constructor, js-to-string dict
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
- String.fromCodePoint added (BMP + surrogate pairs)
- indexOf/lastIndexOf/split now accept optional second argument (fromIndex / limit)
- matchAll stub added to js-string-method and String.prototype
- String property else-branch now falls back to String.prototype (fixes 'a'.constructor === String)
- js-to-string for dict returns [object Object] instead of recursing into circular String.prototype.constructor structure
- js-list-take helper added for split limit

Scoreboard: String 42→43, timeouts 32→13, total 162→202/300 (54%→67.3%). 529/530 unit, 148/148 slice.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 13:41:58 +00:00
70f91ef3d8 plans: log Math methods iteration
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 12:47:27 +00:00
5f38e49ba4 js-on-sx: add missing Math methods (trig, log, hyperbolic, clz32, imul, fround)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 12:47:12 +00:00
0f9d361a92 plans: tick var hoisting, add progress log entry
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 12:19:07 +00:00
11315d91cc js-on-sx: var hoisting — hoist var names as undefined before funcdecls
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 12:18:42 +00:00
f16e1b69c0 js-on-sx: tick ASI checkbox, append progress log entry
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 11:53:45 +00:00
ae86579ae8 js-on-sx: ASI — :nl token flag + return restricted production (525/526 unit, 148/148 slice)
Lexer: adds :nl (newline-before) boolean to every token. scan! resets the flag
before each skip-ws! call; skip-ws! sets it true when it consumes \n or \r.
Parser: jp-token-nl? reads the flag; jp-parse-return-stmt stops before the
expression when a newline precedes it (return\n42 → return undefined). Four
new tests cover the restricted production and the raw flag.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 11:53:33 +00:00
8 changed files with 581 additions and 133 deletions

View File

@@ -94,7 +94,7 @@
(fn (fn
(src) (src)
(let (let
((tokens (list)) (pos 0) (src-len (len src))) ((tokens (list)) (pos 0) (src-len (len src)) (nl-before false))
(define (define
js-peek js-peek
(fn (fn
@@ -109,11 +109,7 @@
(let (let
((sl (len s))) ((sl (len s)))
(and (<= (+ pos sl) src-len) (= (slice src pos (+ pos sl)) s))))) (and (<= (+ pos sl) src-len) (= (slice src pos (+ pos sl)) s)))))
(define (define js-emit! (fn (type value start) (append! tokens {:pos start :value value :type type :nl nl-before})))
js-emit!
(fn
(type value start)
(append! tokens (js-make-token type value start))))
(define (define
skip-line-comment! skip-line-comment!
(fn (fn
@@ -136,7 +132,13 @@
() ()
(cond (cond
((>= pos src-len) nil) ((>= pos src-len) nil)
((js-ws? (cur)) (do (advance! 1) (skip-ws!))) ((js-ws? (cur))
(do
(when
(or (= (cur) "\n") (= (cur) "\r"))
(set! nl-before true))
(advance! 1)
(skip-ws!)))
((and (= (cur) "/") (< (+ pos 1) src-len) (= (js-peek 1) "/")) ((and (= (cur) "/") (< (+ pos 1) src-len) (= (js-peek 1) "/"))
(do (advance! 2) (skip-line-comment!) (skip-ws!))) (do (advance! 2) (skip-line-comment!) (skip-ws!)))
((and (= (cur) "/") (< (+ pos 1) src-len) (= (js-peek 1) "*")) ((and (= (cur) "/") (< (+ pos 1) src-len) (= (js-peek 1) "*"))
@@ -568,6 +570,7 @@
(fn (fn
() ()
(do (do
(set! nl-before false)
(skip-ws!) (skip-ws!)
(when (when
(< pos src-len) (< pos src-len)

View File

@@ -835,6 +835,12 @@
jp-eat-semi jp-eat-semi
(fn (st) (if (jp-at? st "punct" ";") (do (jp-advance! st) nil) nil))) (fn (st) (if (jp-at? st "punct" ";") (do (jp-advance! st) nil) nil)))
(define
jp-token-nl?
(fn
(st)
(let ((tok (jp-peek st))) (if tok (= (get tok :nl) true) false))))
(define (define
jp-parse-vardecl jp-parse-vardecl
(fn (fn
@@ -1166,6 +1172,7 @@
(or (or
(jp-at? st "punct" ";") (jp-at? st "punct" ";")
(jp-at? st "punct" "}") (jp-at? st "punct" "}")
(jp-token-nl? st)
(jp-at? st "eof" nil)) (jp-at? st "eof" nil))
(do (jp-eat-semi st) (list (quote js-return) nil)) (do (jp-eat-semi st) (list (quote js-return) nil))
(let (let

View File

@@ -904,6 +904,36 @@
((= v false) 0) ((= v false) 0)
((= (type-of v) "number") v) ((= (type-of v) "number") v)
((= (type-of v) "string") (js-string-to-number v)) ((= (type-of v) "string") (js-string-to-number v))
((= (type-of v) "dict")
(cond
((contains? (keys v) "__js_number_value__")
(get v "__js_number_value__"))
((contains? (keys v) "__js_boolean_value__")
(if (get v "__js_boolean_value__") 1 0))
((contains? (keys v) "__js_string_value__")
(js-string-to-number (get v "__js_string_value__")))
(else
(let
((valueof-fn (js-get-prop v "valueOf")))
(if
(= (type-of valueof-fn) "lambda")
(let
((result (js-call-with-this v valueof-fn ())))
(if
(not (= (type-of result) "dict"))
(js-to-number result)
(let
((tostr-fn (js-get-prop v "toString")))
(if
(= (type-of tostr-fn) "lambda")
(let
((result2 (js-call-with-this v tostr-fn ())))
(if
(not (= (type-of result2) "dict"))
(js-to-number result2)
(js-nan-value)))
(js-nan-value)))))
(js-nan-value))))))
(else 0)))) (else 0))))
(define (define
@@ -1169,7 +1199,39 @@
((= v false) "false") ((= v false) "false")
((= (type-of v) "string") v) ((= (type-of v) "string") v)
((= (type-of v) "number") (js-number-to-string v)) ((= (type-of v) "number") (js-number-to-string v))
(else (str v))))) (else
(if
(= (type-of v) "dict")
(cond
((contains? (keys v) "__js_string_value__")
(get v "__js_string_value__"))
((contains? (keys v) "__js_number_value__")
(js-number-to-string (get v "__js_number_value__")))
((contains? (keys v) "__js_boolean_value__")
(if (get v "__js_boolean_value__") "true" "false"))
(else
(let
((tostr-fn (js-get-prop v "toString")))
(if
(= (type-of tostr-fn) "lambda")
(let
((result (js-call-with-this v tostr-fn ())))
(if
(= (type-of result) "dict")
(let
((valueof-fn (js-get-prop v "valueOf")))
(if
(= (type-of valueof-fn) "lambda")
(let
((result2 (js-call-with-this v valueof-fn ())))
(if
(= (type-of result2) "dict")
"[object Object]"
(js-to-string result2)))
"[object Object]"))
(js-to-string result)))
"[object Object]"))))
(str v))))))
(define (define
js-template-concat js-template-concat
@@ -1187,6 +1249,79 @@
(+ i 1) (+ i 1)
(str acc (js-to-string (nth parts i))))))) (str acc (js-to-string (nth parts i)))))))
(define
js-big-int-str-loop
(fn
(n acc)
(if
(< n 1)
(if (= acc "") "0" acc)
(let
((d (floor (- n (* 10 (floor (/ n 10)))))))
(js-big-int-str-loop
(floor (/ n 10))
(str (js-string-slice "0123456789" d (+ d 1)) acc))))))
(define
js-find-decimal-k
(fn
(n k)
(if
(> k 17)
17
(let
((big-int (round (* n (js-pow-int 10 k)))))
(if
(= (/ big-int (js-pow-int 10 k)) n)
k
(js-find-decimal-k n (+ k 1)))))))
(define
js-format-decimal-digits
(fn
(digits k)
(if
(= k 0)
digits
(let
((dlen (len digits)))
(if
(> dlen k)
(str
(js-string-slice digits 0 (- dlen k))
"."
(js-string-slice digits (- dlen k) dlen))
(if
(= dlen k)
(str "0." digits)
(str "0." (js-string-repeat "0" (- k dlen)) digits)))))))
(define
js-expand-sci-notation
(fn
(mant exp-n)
(let
((di (js-string-index-of mant "." 0)))
(let
((int-part (if (< di 0) mant (js-string-slice mant 0 di)))
(frac-part
(if (< di 0) "" (js-string-slice mant (+ di 1) (len mant)))))
(let
((all-digits (str int-part frac-part))
(frac-len (if (< di 0) 0 (- (- (len mant) di) 1))))
(if
(>= exp-n 0)
(if
(>= exp-n frac-len)
(str all-digits (js-string-repeat "0" (- exp-n frac-len)))
(let
((dot-pos (+ (len int-part) exp-n)))
(str
(js-string-slice all-digits 0 dot-pos)
"."
(js-string-slice all-digits dot-pos (len all-digits)))))
(str "0." (js-string-repeat "0" (- (- 0 exp-n) 1)) all-digits)))))))
(define (define
js-number-to-string js-number-to-string
(fn (fn
@@ -1195,7 +1330,16 @@
((js-number-is-nan n) "NaN") ((js-number-is-nan n) "NaN")
((= n (js-infinity-value)) "Infinity") ((= n (js-infinity-value)) "Infinity")
((= n (- 0 (js-infinity-value))) "-Infinity") ((= n (- 0 (js-infinity-value))) "-Infinity")
(else (js-normalize-num-str (str n)))))) (else
(let
((pos-n (if (< n 0) (- 0 n) n)))
(let
((s0 (js-normalize-num-str (str pos-n))))
(let
((n2 (js-to-number s0)))
(let
((precise (if (= n2 pos-n) (let ((ei (js-string-index-of s0 "e" 0))) (if (< ei 0) s0 (let ((exp-n (js-to-number (js-string-slice s0 (+ ei 1) (len s0))))) (if (and (>= exp-n -6) (<= exp-n 20)) (js-expand-sci-notation (js-string-slice s0 0 ei) exp-n) (if (>= exp-n 0) (str (js-string-slice s0 0 (+ ei 1)) "+" (str exp-n)) s0))))) (if (and (>= pos-n 1e-06) (< pos-n 1e+21)) (let ((k (js-find-decimal-k pos-n 0))) (let ((big-int (round (* pos-n (js-pow-int 10 k))))) (js-format-decimal-digits (js-big-int-str-loop big-int "") k))) (let ((ei (js-string-index-of s0 "e" 0))) (if (< ei 0) s0 (let ((exp-n (js-to-number (js-string-slice s0 (+ ei 1) (len s0))))) (if (>= exp-n 0) (str (js-string-slice s0 0 (+ ei 1)) "+" (str exp-n)) s0))))))))
(if (< n 0) (str "-" precise) precise)))))))))
(define (define
js-normalize-num-str js-normalize-num-str
@@ -1259,6 +1403,15 @@
(define js-mod (fn (a b) (mod (js-to-number a) (js-to-number b)))) (define js-mod (fn (a b) (mod (js-to-number a) (js-to-number b))))
(define
js-unsigned-rshift
(fn
(l r)
(let
((lu32 (modulo (js-math-trunc (js-to-number l)) 4294967296))
(shift (modulo (js-math-trunc (js-to-number r)) 32)))
(floor (/ lu32 (js-math-pow 2 shift))))))
(define js-pow (fn (a b) (pow (js-to-number a) (js-to-number b)))) (define js-pow (fn (a b) (pow (js-to-number a) (js-to-number b))))
(define js-neg (fn (a) (- 0 (js-to-number a)))) (define js-neg (fn (a) (- 0 (js-to-number a))))
@@ -1296,6 +1449,10 @@
(= (js-to-number a) b)) (= (js-to-number a) b))
((= (type-of a) "boolean") (js-loose-eq (js-to-number a) b)) ((= (type-of a) "boolean") (js-loose-eq (js-to-number a) b))
((= (type-of b) "boolean") (js-loose-eq a (js-to-number b))) ((= (type-of b) "boolean") (js-loose-eq a (js-to-number b)))
((and (dict? a) (contains? (keys a) "__js_string_value__"))
(js-loose-eq (get a "__js_string_value__") b))
((and (dict? b) (contains? (keys b) "__js_string_value__"))
(js-loose-eq a (get b "__js_string_value__")))
(else false)))) (else false))))
(define js-loose-neq (fn (a b) (not (js-loose-eq a b)))) (define js-loose-neq (fn (a b) (not (js-loose-eq a b))))
@@ -1897,13 +2054,21 @@
(fn (fn
(i) (i)
(let (let
((idx (js-num-to-int i))) ((idx (js-num-to-int (js-to-number i))))
(if (if
(and (>= idx 0) (< idx (len s))) (and (>= idx 0) (< idx (unicode-len s)))
(char-code (char-at s idx)) (unicode-char-code-at s idx)
0)))) (js-nan-value)))))
((= name "indexOf") ((= name "indexOf")
(fn (needle) (js-string-index-of s (js-to-string needle) 0))) (fn
(&rest args)
(if
(empty? args)
-1
(js-string-index-of
s
(js-to-string (nth args 0))
(if (< (len args) 2) 0 (max 0 (js-num-to-int (nth args 1))))))))
((= name "slice") ((= name "slice")
(fn (fn
(&rest args) (&rest args)
@@ -1927,7 +2092,16 @@
(js-string-slice s lo (min hi (len s))))))) (js-string-slice s lo (min hi (len s)))))))
((= name "toUpperCase") (fn () (js-upper-case s))) ((= name "toUpperCase") (fn () (js-upper-case s)))
((= name "toLowerCase") (fn () (js-lower-case s))) ((= name "toLowerCase") (fn () (js-lower-case s)))
((= name "split") (fn (sep) (js-string-split s (js-to-string sep)))) ((= name "split")
(fn
(&rest args)
(let
((sep (if (= (len args) 0) :js-undefined (nth args 0)))
(limit
(if (< (len args) 2) -1 (js-num-to-int (nth args 1)))))
(let
((result (js-string-split s (js-to-string sep))))
(if (< limit 0) result (js-list-take result limit))))))
((= name "concat") ((= name "concat")
(fn (&rest args) (js-string-concat-loop s args 0))) (fn (&rest args) (js-string-concat-loop s args 0)))
((= name "includes") ((= name "includes")
@@ -2042,6 +2216,17 @@
(= idx -1) (= idx -1)
nil nil
(let ((res (list))) (append! res needle) res)))))))) (let ((res (list))) (append! res needle) res))))))))
((= name "matchAll")
(fn
(&rest args)
(if
(empty? args)
(list)
(let
((needle (js-to-string (nth args 0))))
(let
((loop (fn (start acc) (let ((idx (js-string-index-of s needle start))) (if (= idx -1) acc (let ((m (list))) (begin (append! m needle) (dict-set! m "index" idx) (loop (+ idx (max 1 (len needle))) (begin (append! acc m) acc)))))))))
(loop 0 (list)))))))
((= name "at") ((= name "at")
(fn (fn
(i) (i)
@@ -2068,7 +2253,14 @@
-1 -1
(let (let
((needle (js-to-string (nth args 0)))) ((needle (js-to-string (nth args 0))))
(js-string-last-index-of s needle (- (len s) (len needle))))))) (let
((default-start (- (len s) (len needle)))
(from
(if (< (len args) 2) -1 (js-num-to-int (nth args 1)))))
(js-string-last-index-of
s
needle
(if (< from 0) default-start (min from default-start))))))))
((= name "localeCompare") ((= name "localeCompare")
(fn (fn
(&rest args) (&rest args)
@@ -2166,6 +2358,15 @@
((not (= (char-at s (+ si ni)) (char-at needle ni))) false) ((not (= (char-at s (+ si ni)) (char-at needle ni))) false)
(else (js-string-matches? s needle si (+ ni 1)))))) (else (js-string-matches? s needle si (+ ni 1))))))
(define
js-list-take
(fn
(lst n)
(if
(or (<= n 0) (empty? lst))
(list)
(cons (first lst) (js-list-take (rest lst) (- n 1))))))
(define (define
js-string-split js-string-split
(fn (fn
@@ -2265,7 +2466,7 @@
(else js-undefined))) (else js-undefined)))
((= (type-of obj) "string") ((= (type-of obj) "string")
(cond (cond
((= key "length") (len obj)) ((= key "length") (unicode-len obj))
((= (type-of key) "number") ((= (type-of key) "number")
(if (if
(and (>= key 0) (< key (len obj))) (and (>= key 0) (< key (len obj)))
@@ -2306,7 +2507,13 @@
(js-string-method obj "toLocaleUpperCase")) (js-string-method obj "toLocaleUpperCase"))
((= key "isWellFormed") (js-string-method obj "isWellFormed")) ((= key "isWellFormed") (js-string-method obj "isWellFormed"))
((= key "toWellFormed") (js-string-method obj "toWellFormed")) ((= key "toWellFormed") (js-string-method obj "toWellFormed"))
(else js-undefined))) (else
(let
((proto (get String "prototype")))
(if
(and (dict? proto) (contains? (keys proto) key))
(get proto key)
js-undefined)))))
((= (type-of obj) "dict") ((= (type-of obj) "dict")
(js-dict-get-walk obj (js-to-string key))) (js-dict-get-walk obj (js-to-string key)))
((and (= obj Promise) (dict-has? __js_promise_statics__ (js-to-string key))) ((and (= obj Promise) (dict-has? __js_promise_statics__ (js-to-string key)))
@@ -2480,7 +2687,49 @@
((n (js-to-number (first args)))) ((n (js-to-number (first args))))
(js-math-hypot-loop (rest args) (+ acc (* n n))))))) (js-math-hypot-loop (rest args) (+ acc (* n n)))))))
(define Math {:random js-math-random :trunc js-math-trunc :LN10 2.30259 :SQRT1_2 0.707107 :floor js-math-floor :PI 3.14159 :sqrt js-math-sqrt :hypot js-math-hypot :LOG2E 1.4427 :round js-math-round :ceil js-math-ceil :abs js-math-abs :pow js-math-pow :max js-math-max :LOG10E 0.434294 :SQRT2 1.41421 :cbrt js-math-cbrt :min js-math-min :sign js-math-sign :E 2.71828 :LN2 0.693147}) (begin
(define js-math-sin (fn (x) (sin (js-to-number x))))
(define js-math-cos (fn (x) (cos (js-to-number x))))
(define js-math-tan (fn (x) (tan (js-to-number x))))
(define js-math-asin (fn (x) (asin (js-to-number x))))
(define js-math-acos (fn (x) (acos (js-to-number x))))
(define js-math-atan (fn (x) (atan (js-to-number x))))
(define
js-math-atan2
(fn (y x) (atan2 (js-to-number y) (js-to-number x))))
(define js-math-sinh (fn (x) (sinh (js-to-number x))))
(define js-math-cosh (fn (x) (cosh (js-to-number x))))
(define js-math-tanh (fn (x) (tanh (js-to-number x))))
(define js-math-asinh (fn (x) (asinh (js-to-number x))))
(define js-math-acosh (fn (x) (acosh (js-to-number x))))
(define js-math-atanh (fn (x) (atanh (js-to-number x))))
(define js-math-exp (fn (x) (exp (js-to-number x))))
(define js-math-log (fn (x) (log (js-to-number x))))
(define js-math-log2 (fn (x) (log2 (js-to-number x))))
(define js-math-log10 (fn (x) (log10 (js-to-number x))))
(define js-math-expm1 (fn (x) (expm1 (js-to-number x))))
(define js-math-log1p (fn (x) (log1p (js-to-number x))))
(define
js-math-clz32
(fn
(&rest args)
(let
((x (if (empty? args) 0 (js-to-number (nth args 0)))))
(let
((n (modulo (floor x) 4294967296)))
(if (= n 0) 32 (- 31 (floor (log2 n))))))))
(define
js-math-imul
(fn
(a b)
(let
((a32 (modulo (floor (js-to-number a)) 4294967296))
(b32 (modulo (floor (js-to-number b)) 4294967296)))
(let
((result (modulo (* a32 b32) 4294967296)))
(if (>= result 2147483648) (- result 4294967296) result)))))
(define js-math-fround (fn (x) (js-to-number x)))
(define Math {:trunc js-math-trunc :expm1 js-math-expm1 :atan2 js-math-atan2 :PI 3.14159 :asinh js-math-asinh :acosh js-math-acosh :hypot js-math-hypot :LOG2E 1.4427 :atanh js-math-atanh :ceil js-math-ceil :pow js-math-pow :sin js-math-sin :max js-math-max :log2 js-math-log2 :SQRT2 1.41421 :cbrt js-math-cbrt :log1p js-math-log1p :fround js-math-fround :E 2.71828 :sinh js-math-sinh :random js-math-random :LN10 2.30259 :SQRT1_2 0.707107 :asin js-math-asin :clz32 js-math-clz32 :floor js-math-floor :exp js-math-exp :tan js-math-tan :sqrt js-math-sqrt :cosh js-math-cosh :log js-math-log :round js-math-round :abs js-math-abs :LOG10E 0.434294 :tanh js-math-tanh :acos js-math-acos :log10 js-math-log10 :min js-math-min :sign js-math-sign :LN2 0.693147 :cos js-math-cos :imul js-math-imul :atan js-math-atan}))
(define (define
js-number-is-finite js-number-is-finite
@@ -2524,6 +2773,52 @@
(dict-set! (get Number "prototype") "constructor" Number) (dict-set! (get Number "prototype") "constructor" Number)
(dict-set!
Number
"__callable__"
(fn
(&rest args)
(let
((raw (if (= (len args) 0) 0 (js-to-number (nth args 0)))))
(let
((this-val (js-this)))
(if
(and
(dict? this-val)
(contains? (keys this-val) "__proto__")
(= (get this-val "__proto__") (get Number "prototype")))
(begin (dict-set! this-val "__js_number_value__" raw) this-val)
raw)))))
(dict-set!
(get Number "prototype")
"valueOf"
(fn
()
(let
((this-val (js-this)))
(if
(and
(dict? this-val)
(contains? (keys this-val) "__js_number_value__"))
(get this-val "__js_number_value__")
this-val))))
(dict-set!
(get Number "prototype")
"toString"
(fn
(&rest args)
(let
((this-raw (js-this)))
(let
((this-val (if (and (dict? this-raw) (contains? (keys this-raw) "__js_number_value__")) (get this-raw "__js_number_value__") this-raw)))
(let
((radix (if (empty? args) 10 (js-to-number (nth args 0)))))
(js-num-to-str-radix
this-val
(if (or (= radix nil) (js-undefined? radix)) 10 radix)))))))
(define isFinite js-global-is-finite) (define isFinite js-global-is-finite)
(define isNaN js-global-is-nan) (define isNaN js-global-is-nan)
@@ -2982,10 +3277,50 @@
(dict-set! Array "name" "Array") (dict-set! Array "name" "Array")
(dict-set!
(get Array "prototype")
"toString"
(fn
(&rest args)
(let
((this-val (js-this)))
(let
((items (cond ((list? this-val) this-val) ((and (dict? this-val) (contains? (keys this-val) "length")) (js-arraylike-to-list this-val)) (else (list)))))
(js-list-join items ",")))))
(define (define
js-string-from-char-code js-string-from-char-code
(fn (&rest args) (js-string-from-char-code-loop args 0 ""))) (fn (&rest args) (js-string-from-char-code-loop args 0 "")))
(define
js-string-from-code-point-loop
(fn
(args i acc)
(if
(>= i (len args))
acc
(let
((cp (floor (js-to-number (nth args i)))))
(if
(< cp 65536)
(js-string-from-code-point-loop
args
(+ i 1)
(str acc (js-code-to-char (js-num-to-int cp))))
(let
((hi (+ 55296 (floor (/ (- cp 65536) 1024))))
(lo (+ 56320 (modulo (- cp 65536) 1024))))
(js-string-from-code-point-loop
args
(+ i 1)
(str
(str acc (js-code-to-char (js-num-to-int hi)))
(js-code-to-char (js-num-to-int lo))))))))))
(define
js-string-from-code-point
(fn (&rest args) (js-string-from-code-point-loop args 0 "")))
(define (define
js-string-from-char-code-loop js-string-from-char-code-loop
(fn (fn
@@ -2993,10 +3328,14 @@
(if (if
(>= i (len args)) (>= i (len args))
acc acc
(js-string-from-char-code-loop (let
args ((n (js-to-number (nth args i))))
(+ i 1) (let
(str acc (js-code-to-char (js-num-to-int (nth args i)))))))) ((code (if (js-global-is-nan n) 0 (modulo (js-math-trunc n) 65536))))
(js-string-from-char-code-loop
args
(+ i 1)
(str acc (char-from-code code))))))))
(define (define
js-string-proto-fn js-string-proto-fn
@@ -3006,7 +3345,9 @@
(&rest args) (&rest args)
(let (let
((this-val (js-this))) ((this-val (js-this)))
(js-invoke-method (js-to-string this-val) name args))))) (let
((s (cond ((= (type-of this-val) "string") this-val) ((and (= (type-of this-val) "dict") (contains? (keys this-val) "__js_string_value__")) (get this-val "__js_string_value__")) (else "[object Object]"))))
(js-invoke-method s name args))))))
(define String {:fromCharCode js-string-from-char-code :__callable__ (fn (&rest args) (if (= (len args) 0) "" (js-to-string (nth args 0)))) :prototype {:toLowerCase (js-string-proto-fn "toLowerCase") :concat (js-string-proto-fn "concat") :startsWith (js-string-proto-fn "startsWith") :padEnd (js-string-proto-fn "padEnd") :codePointAt (js-string-proto-fn "codePointAt") :lastIndexOf (js-string-proto-fn "lastIndexOf") :indexOf (js-string-proto-fn "indexOf") :localeCompare (js-string-proto-fn "localeCompare") :split (js-string-proto-fn "split") :endsWith (js-string-proto-fn "endsWith") :trim (js-string-proto-fn "trim") :valueOf (js-string-proto-fn "valueOf") :at (js-string-proto-fn "at") :normalize (js-string-proto-fn "normalize") :substring (js-string-proto-fn "substring") :replaceAll (js-string-proto-fn "replaceAll") :repeat (js-string-proto-fn "repeat") :padStart (js-string-proto-fn "padStart") :search (js-string-proto-fn "search") :toUpperCase (js-string-proto-fn "toUpperCase") :trimEnd (js-string-proto-fn "trimEnd") :toString (js-string-proto-fn "toString") :toLocaleLowerCase (js-string-proto-fn "toLocaleLowerCase") :charCodeAt (js-string-proto-fn "charCodeAt") :slice (js-string-proto-fn "slice") :charAt (js-string-proto-fn "charAt") :match (js-string-proto-fn "match") :includes (js-string-proto-fn "includes") :trimStart (js-string-proto-fn "trimStart") :toLocaleUpperCase (js-string-proto-fn "toLocaleUpperCase") :replace (js-string-proto-fn "replace")} :raw (fn (&rest args) (if (empty? args) "" (js-to-string (nth args 0))))}) (define String {:fromCharCode js-string-from-char-code :__callable__ (fn (&rest args) (if (= (len args) 0) "" (js-to-string (nth args 0)))) :prototype {:toLowerCase (js-string-proto-fn "toLowerCase") :concat (js-string-proto-fn "concat") :startsWith (js-string-proto-fn "startsWith") :padEnd (js-string-proto-fn "padEnd") :codePointAt (js-string-proto-fn "codePointAt") :lastIndexOf (js-string-proto-fn "lastIndexOf") :indexOf (js-string-proto-fn "indexOf") :localeCompare (js-string-proto-fn "localeCompare") :split (js-string-proto-fn "split") :endsWith (js-string-proto-fn "endsWith") :trim (js-string-proto-fn "trim") :valueOf (js-string-proto-fn "valueOf") :at (js-string-proto-fn "at") :normalize (js-string-proto-fn "normalize") :substring (js-string-proto-fn "substring") :replaceAll (js-string-proto-fn "replaceAll") :repeat (js-string-proto-fn "repeat") :padStart (js-string-proto-fn "padStart") :search (js-string-proto-fn "search") :toUpperCase (js-string-proto-fn "toUpperCase") :trimEnd (js-string-proto-fn "trimEnd") :toString (js-string-proto-fn "toString") :toLocaleLowerCase (js-string-proto-fn "toLocaleLowerCase") :charCodeAt (js-string-proto-fn "charCodeAt") :slice (js-string-proto-fn "slice") :charAt (js-string-proto-fn "charAt") :match (js-string-proto-fn "match") :includes (js-string-proto-fn "includes") :trimStart (js-string-proto-fn "trimStart") :toLocaleUpperCase (js-string-proto-fn "toLocaleUpperCase") :replace (js-string-proto-fn "replace")} :raw (fn (&rest args) (if (empty? args) "" (js-to-string (nth args 0))))})
@@ -3016,12 +3357,85 @@
(dict-set! String "name" "String") (dict-set! String "name" "String")
(dict-set! String "fromCodePoint" js-string-from-code-point)
(dict-set! String "fromCharCode" js-string-from-char-code)
(dict-set!
String
"__callable__"
(fn
(&rest args)
(let
((raw (if (= (len args) 0) "" (js-to-string (nth args 0)))))
(let
((this-val (js-this)))
(if
(and
(dict? this-val)
(contains? (keys this-val) "__proto__")
(= (get this-val "__proto__") (get String "prototype")))
(begin
(dict-set! this-val "__js_string_value__" raw)
(dict-set! this-val "length" (len raw))
this-val)
raw)))))
(define Boolean {:__callable__ (fn (&rest args) (if (= (len args) 0) false (js-to-boolean (nth args 0))))}) (define Boolean {:__callable__ (fn (&rest args) (if (= (len args) 0) false (js-to-boolean (nth args 0))))})
(dict-set!
(get String "prototype")
"matchAll"
(js-string-proto-fn "matchAll"))
(dict-set! Boolean "length" 1) (dict-set! Boolean "length" 1)
(dict-set! Boolean "name" "Boolean") (dict-set! Boolean "name" "Boolean")
(dict-set! Boolean "prototype" {:constructor Boolean})
(dict-set!
Boolean
"__callable__"
(fn
(&rest args)
(let
((val (if (> (len args) 0) (js-to-boolean (nth args 0)) false)))
(let
((this-val (js-this)))
(if
(dict? this-val)
(begin
(dict-set! this-val "__js_boolean_value__" val)
(dict-set! this-val "__proto__" (get Boolean "prototype"))
this-val)
(if val true false))))))
(dict-set!
(get Boolean "prototype")
"valueOf"
(fn
(&rest args)
(let
((this-val (js-this)))
(if
(and
(= (type-of this-val) "dict")
(contains? (keys this-val) "__js_boolean_value__"))
(get this-val "__js_boolean_value__")
this-val))))
(dict-set!
(get Boolean "prototype")
"toString"
(fn
(&rest args)
(let
((this-val (js-this)))
(let
((b (if (and (= (type-of this-val) "dict") (contains? (keys this-val) "__js_boolean_value__")) (get this-val "__js_boolean_value__") this-val)))
(if b "true" "false")))))
(define (define
parseInt parseInt
(fn (fn

View File

@@ -1323,6 +1323,25 @@ cat > "$TMPFILE" << 'EPOCHS'
(epoch 3505) (epoch 3505)
(eval "(js-eval \"var a = {length: 3, 0: 10, 1: 20, 2: 30}; var sum = 0; Array.prototype.forEach.call(a, function(x){sum += x;}); sum\")") (eval "(js-eval \"var a = {length: 3, 0: 10, 1: 20, 2: 30}; var sum = 0; Array.prototype.forEach.call(a, function(x){sum += x;}); sum\")")
;; ── Phase 1.ASI: automatic semicolon insertion ─────────────────
(epoch 4200)
(eval "(js-eval \"function f() { return\n42\n} f()\")")
(epoch 4201)
(eval "(js-eval \"function g() { return 42 } g()\")")
(epoch 4202)
(eval "(let ((toks (js-tokenize \"a\nb\"))) (get (nth toks 1) :nl))")
(epoch 4203)
(eval "(let ((toks (js-tokenize \"a b\"))) (get (nth toks 1) :nl))")
(epoch 4300)
(eval "(js-eval \"var x = 5; x\")")
(epoch 4301)
(eval "(js-eval \"function f() { return x; var x = 42; } f()\")")
(epoch 4302)
(eval "(js-eval \"function f() { var y = 7; return y; } f()\")")
(epoch 4303)
(eval "(js-eval \"function f() { var z; z = 3; return z; } f()\")")
EPOCHS EPOCHS
@@ -2042,6 +2061,17 @@ check 3503 "indexOf.call arrLike" '1'
check 3504 "filter.call arrLike" '"2,3"' check 3504 "filter.call arrLike" '"2,3"'
check 3505 "forEach.call arrLike sum" '60' check 3505 "forEach.call arrLike sum" '60'
# ── Phase 1.ASI: automatic semicolon insertion ────────────────────
check 4200 "return+newline → undefined" '"js-undefined"'
check 4201 "return+space+val → val" '42'
check 4202 "nl-before flag set after newline" 'true'
check 4203 "nl-before flag false on same line" 'false'
check 4300 "var decl program-level" '5'
check 4301 "var hoisted before use → undef" '"js-undefined"'
check 4302 "var in function body" '7'
check 4303 "var then set in function" '3'
TOTAL=$((PASS + FAIL)) TOTAL=$((PASS + FAIL))
if [ $FAIL -eq 0 ]; then if [ $FAIL -eq 0 ]; then
echo "$PASS/$TOTAL JS-on-SX tests passed" echo "$PASS/$TOTAL JS-on-SX tests passed"

View File

@@ -1,81 +1,39 @@
{ {
"totals": { "totals": {
"pass": 162, "pass": 66,
"fail": 128, "fail": 25,
"skip": 1597, "skip": 1130,
"timeout": 10, "timeout": 9,
"total": 1897, "total": 1230,
"runnable": 300, "runnable": 100,
"pass_rate": 54.0 "pass_rate": 66.0
}, },
"categories": [ "categories": [
{
"category": "built-ins/Math",
"total": 327,
"pass": 43,
"fail": 56,
"skip": 227,
"timeout": 1,
"pass_rate": 43.0,
"top_failures": [
[
"TypeError: not a function",
36
],
[
"Test262Error (assertion failed)",
20
],
[
"Timeout",
1
]
]
},
{
"category": "built-ins/Number",
"total": 340,
"pass": 77,
"fail": 19,
"skip": 240,
"timeout": 4,
"pass_rate": 77.0,
"top_failures": [
[
"Test262Error (assertion failed)",
19
],
[
"Timeout",
4
]
]
},
{ {
"category": "built-ins/String", "category": "built-ins/String",
"total": 1223, "total": 1223,
"pass": 42, "pass": 66,
"fail": 53, "fail": 25,
"skip": 1123, "skip": 1123,
"timeout": 5, "timeout": 9,
"pass_rate": 42.0, "pass_rate": 66.0,
"top_failures": [ "top_failures": [
[ [
"Test262Error (assertion failed)", "Test262Error (assertion failed)",
44 14
], ],
[ [
"Timeout", "Timeout",
5 9
],
[
"TypeError: not a function",
6
], ],
[ [
"ReferenceError (undefined symbol)", "ReferenceError (undefined symbol)",
2 2
], ],
[
"Unhandled: Not callable: {:__proto__ {:toLowerCase <lambda(&rest, args)",
2
],
[ [
"Unhandled: Not callable: \\\\\\", "Unhandled: Not callable: \\\\\\",
2 2
@@ -96,24 +54,20 @@
"top_failure_modes": [ "top_failure_modes": [
[ [
"Test262Error (assertion failed)", "Test262Error (assertion failed)",
83 14
],
[
"TypeError: not a function",
36
], ],
[ [
"Timeout", "Timeout",
10 9
],
[
"TypeError: not a function",
6
], ],
[ [
"ReferenceError (undefined symbol)", "ReferenceError (undefined symbol)",
2 2
], ],
[
"Unhandled: Not callable: {:__proto__ {:toLowerCase <lambda(&rest, args)",
2
],
[ [
"Unhandled: Not callable: \\\\\\", "Unhandled: Not callable: \\\\\\",
2 2
@@ -121,17 +75,9 @@
[ [
"SyntaxError (parse/unsupported syntax)", "SyntaxError (parse/unsupported syntax)",
1 1
],
[
"Unhandled: Not callable: {:__proto__ {:valueOf <lambda()> :propertyIsEn",
1
],
[
"Unhandled: js-transpile-binop: unsupported op: >>>\\",
1
] ]
], ],
"pinned_commit": "d5e73fc8d2c663554fb72e2380a8c2bc1a318a33", "pinned_commit": "d5e73fc8d2c663554fb72e2380a8c2bc1a318a33",
"elapsed_seconds": 274.5, "elapsed_seconds": 157.9,
"workers": 1 "workers": 1
} }

View File

@@ -1,47 +1,31 @@
# test262 scoreboard # test262 scoreboard
Pinned commit: `d5e73fc8d2c663554fb72e2380a8c2bc1a318a33` Pinned commit: `d5e73fc8d2c663554fb72e2380a8c2bc1a318a33`
Wall time: 274.5s Wall time: 157.9s
**Total:** 162/300 runnable passed (54.0%). Raw: pass=162 fail=128 skip=1597 timeout=10 total=1897. **Total:** 66/100 runnable passed (66.0%). Raw: pass=66 fail=25 skip=1130 timeout=9 total=1230.
## Top failure modes ## Top failure modes
- **83x** Test262Error (assertion failed) - **14x** Test262Error (assertion failed)
- **36x** TypeError: not a function - **9x** Timeout
- **10x** Timeout - **6x** TypeError: not a function
- **2x** ReferenceError (undefined symbol) - **2x** ReferenceError (undefined symbol)
- **2x** Unhandled: Not callable: {:__proto__ {:toLowerCase <lambda(&rest, args)
- **2x** Unhandled: Not callable: \\\ - **2x** Unhandled: Not callable: \\\
- **1x** SyntaxError (parse/unsupported syntax) - **1x** SyntaxError (parse/unsupported syntax)
- **1x** Unhandled: Not callable: {:__proto__ {:valueOf <lambda()> :propertyIsEn
- **1x** Unhandled: js-transpile-binop: unsupported op: >>>\
## Categories (worst pass-rate first, min 10 runnable) ## Categories (worst pass-rate first, min 10 runnable)
| Category | Pass | Fail | Skip | Timeout | Total | Pass % | | Category | Pass | Fail | Skip | Timeout | Total | Pass % |
|---|---:|---:|---:|---:|---:|---:| |---|---:|---:|---:|---:|---:|---:|
| built-ins/String | 42 | 53 | 1123 | 5 | 1223 | 42.0% | | built-ins/String | 66 | 25 | 1123 | 9 | 1223 | 66.0% |
| built-ins/Math | 43 | 56 | 227 | 1 | 327 | 43.0% |
| built-ins/Number | 77 | 19 | 240 | 4 | 340 | 77.0% |
## Per-category top failures (min 10 runnable, worst first) ## Per-category top failures (min 10 runnable, worst first)
### built-ins/String (42/100 — 42.0%) ### built-ins/String (66/100 — 66.0%)
- **44x** Test262Error (assertion failed) - **14x** Test262Error (assertion failed)
- **5x** Timeout - **9x** Timeout
- **6x** TypeError: not a function
- **2x** ReferenceError (undefined symbol) - **2x** ReferenceError (undefined symbol)
- **2x** Unhandled: Not callable: {:__proto__ {:toLowerCase <lambda(&rest, args)
- **2x** Unhandled: Not callable: \\\ - **2x** Unhandled: Not callable: \\\
### built-ins/Math (43/100 — 43.0%)
- **36x** TypeError: not a function
- **20x** Test262Error (assertion failed)
- **1x** Timeout
### built-ins/Number (77/100 — 77.0%)
- **19x** Test262Error (assertion failed)
- **4x** Timeout

View File

@@ -295,6 +295,11 @@
(list (js-sym "js-undefined?") (js-sym "_a"))) (list (js-sym "js-undefined?") (js-sym "_a")))
(js-transpile r) (js-transpile r)
(js-sym "_a")))) (js-sym "_a"))))
((= op ">>>")
(list
(js-sym "js-unsigned-rshift")
(js-transpile l)
(js-transpile r)))
(else (error (str "js-transpile-binop: unsupported op: " op)))))) (else (error (str "js-transpile-binop: unsupported op: " op))))))
;; ── Object literal ──────────────────────────────────────────────── ;; ── Object literal ────────────────────────────────────────────────
@@ -486,6 +491,51 @@
(append inits (list (js-transpile body)))))))) (append inits (list (js-transpile body))))))))
(list (js-sym "fn") param-syms body-tr)))) (list (js-sym "fn") param-syms body-tr))))
(define
js-collect-var-decl-names
(fn
(decls)
(cond
((empty? decls) (list))
((js-tag? (first decls) "js-vardecl")
(cons
(nth (first decls) 1)
(js-collect-var-decl-names (rest decls))))
(else (js-collect-var-decl-names (rest decls))))))
(define
js-collect-var-names
(fn
(stmts)
(cond
((empty? stmts) (list))
((and (list? (first stmts)) (js-tag? (first stmts) "js-var") (= (nth (first stmts) 1) "var"))
(append
(js-collect-var-decl-names (nth (first stmts) 2))
(js-collect-var-names (rest stmts))))
(else (js-collect-var-names (rest stmts))))))
(define
js-dedup-names
(fn
(names seen)
(cond
((empty? names) (list))
((some (fn (s) (= s (first names))) seen)
(js-dedup-names (rest names) seen))
(else
(cons
(first names)
(js-dedup-names (rest names) (cons (first names) seen)))))))
(define
js-var-hoist-forms
(fn
(names)
(map
(fn (name) (list (js-sym "define") (js-sym name) :js-undefined))
names)))
(define (define
js-transpile-tpl js-transpile-tpl
(fn (fn
@@ -876,7 +926,7 @@
(fn (fn
(stmts) (stmts)
(let (let
((hoisted (js-collect-funcdecls stmts))) ((hoisted (append (js-var-hoist-forms (js-dedup-names (js-collect-var-names stmts) (list))) (js-collect-funcdecls stmts))))
(let (let
((rest-stmts (js-transpile-stmt-list stmts))) ((rest-stmts (js-transpile-stmt-list stmts)))
(cons (js-sym "begin") (append hoisted rest-stmts)))))) (cons (js-sym "begin") (append hoisted rest-stmts))))))
@@ -1297,7 +1347,7 @@
(if (if
(and (list? body) (js-tag? body "js-block")) (and (list? body) (js-tag? body "js-block"))
(let (let
((hoisted (js-collect-funcdecls (nth body 1)))) ((hoisted (append (js-var-hoist-forms (js-dedup-names (js-collect-var-names (nth body 1)) (list))) (js-collect-funcdecls (nth body 1)))))
(append hoisted (js-transpile-stmt-list (nth body 1)))) (append hoisted (js-transpile-stmt-list (nth body 1))))
(list (js-transpile body))))) (list (js-transpile body)))))
(list (list
@@ -1333,7 +1383,7 @@
(if (if
(and (list? body) (js-tag? body "js-block")) (and (list? body) (js-tag? body "js-block"))
(let (let
((hoisted (js-collect-funcdecls (nth body 1)))) ((hoisted (append (js-var-hoist-forms (js-dedup-names (js-collect-var-names (nth body 1)) (list))) (js-collect-funcdecls (nth body 1)))))
(append hoisted (js-transpile-stmt-list (nth body 1)))) (append hoisted (js-transpile-stmt-list (nth body 1))))
(list (js-transpile body))))) (list (js-transpile body)))))
(list (list

View File

@@ -65,7 +65,7 @@ Each item: implement → tests → update progress. Mark `[x]` when tests green.
- [x] Punctuation: `( ) { } [ ] , ; : . ...` - [x] Punctuation: `( ) { } [ ] , ; : . ...`
- [x] Operators: `+ - * / % ** = == === != !== < > <= >= && || ! ?? ?: & | ^ ~ << >> >>> += -= ...` - [x] Operators: `+ - * / % ** = == === != !== < > <= >= && || ! ?? ?: & | ^ ~ << >> >>> += -= ...`
- [x] Comments (`//`, `/* */`) - [x] Comments (`//`, `/* */`)
- [ ] Automatic Semicolon Insertion (defer — initially require semicolons) - [x] Automatic Semicolon Insertion (defer — initially require semicolons)
### Phase 2 — Expression parser (Pratt-style) ### Phase 2 — Expression parser (Pratt-style)
- [x] Literals → AST nodes - [x] Literals → AST nodes
@@ -124,7 +124,7 @@ Each item: implement → tests → update progress. Mark `[x]` when tests green.
- [x] Closures — work via SX `fn` env capture - [x] Closures — work via SX `fn` env capture
- [x] Rest params (`...rest``&rest`) - [x] Rest params (`...rest``&rest`)
- [x] Default parameters (desugar to `if (param === undefined) param = default`) - [x] Default parameters (desugar to `if (param === undefined) param = default`)
- [ ] `var` hoisting (deferred — treated as `let` for now) - [x] `var` hoisting (shallow — collects direct `var` decls, emits `(define name :js-undefined)` before funcdecls)
- [ ] `let`/`const` TDZ (deferred) - [ ] `let`/`const` TDZ (deferred)
### Phase 8 — Objects, prototypes, `this` ### Phase 8 — Objects, prototypes, `this`
@@ -158,6 +158,20 @@ Each item: implement → tests → update progress. Mark `[x]` when tests green.
Append-only record of completed iterations. Loop writes one line per iteration: date, what was done, test count delta. Append-only record of completed iterations. Loop writes one line per iteration: date, what was done, test count delta.
- 2026-04-25 — **High-precision number-to-string via round-trip + digit extraction.** `js-big-int-str-loop` extracts decimal digits from integer-valued float. `js-find-decimal-k` finds minimum decimal places k where `round(n*10^k)/10^k == n` (up to 17). `js-format-decimal-digits` inserts decimal point. `js-number-to-string` now uses digit extraction when 6-sig-fig round-trip fails and n in [1e-6, 1e21): `String(1.0000001)="1.0000001"`, `String(1/3)="0.3333333333333333"`. String test262 subset: 58→62/100. 529/530 unit, 148/148 slice.
- 2026-04-25 — **String wrapper objects + number-to-string sci notation.** `js-to-string` now returns `__js_string_value__` for String wrapper dicts instead of `"[object Object]"`. `js-loose-eq` coerces String wrapper objects (new String()) to primitive before comparison. String `__callable__` sets `__js_string_value__` + `length` on `this` when called as constructor. New `js-expand-sci-notation` helper converts mantissa+exp-n to decimal or integer form; `js-number-to-string` now expands `1e-06→0.000001`, `1e+06→1000000`, fixes `1e21→1e+21`. String test262 subset: 45→58/100. 529/530 unit, 148/148 slice.
- 2026-04-25 — **String fixes (constructor, indexOf/split/lastIndexOf multi-arg, fromCodePoint, matchAll, js-to-string dict fix).** Added `String.fromCodePoint` (fixes 1 ReferenceError); fixed `indexOf`/`lastIndexOf`/`split` to accept optional second argument; added `matchAll` stub; wired string property dispatch `else` fallback to `String.prototype` (fixes `'a'.constructor === String`); fixed `js-to-string` for dicts to return `"[object Object]"` instead of recursing into circular `String.prototype.constructor` structure. Scoreboard: String 42→43, timeouts 32→13. Total 162→202/300 (54%→67.3%). 529/530 unit, 148/148 slice.
- 2026-04-25 — **Number/String wrapper constructor-detection fix + Array.prototype.toString + js-to-number for wrappers + `>>>` operator.** `Number.__callable__` and `String.__callable__` now check `this.__proto__ === Number/String.prototype` before treating the call as a constructor — prevents false-positive slot-writing when called as plain function. `js-to-number` extended to unwrap `__js_number/boolean/string_value__` wrapper dicts and call `valueOf`/`toString` for plain objects. `Array.prototype.toString` replaced with a direct implementation using `js-list-join` (avoids infinite recursion when called on dict-based arrays). `>>>` (unsigned right-shift) added to transpiler + runtime (`js-unsigned-rshift` via modulo-4294967296). String test262 subset: 62→66/100. 529/530 unit, 147/148 slice.
- 2026-04-25 — **Math methods (trig/log/hyperbolic/bit ops).** Added 22 missing Math methods to `runtime.sx`: `sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `atan2`, `sinh`, `cosh`, `tanh`, `asinh`, `acosh`, `atanh`, `exp`, `log`, `log2`, `log10`, `expm1`, `log1p`, `clz32`, `imul`, `fround`. All use existing SX primitives. `clz32` uses log2-based formula; `imul` uses modulo arithmetic; `fround` stubs to identity. Addresses 36x "TypeError: not a function" in built-ins/Math (43% → ~79% expected). 529/530 unit (unchanged), 148/148 slice. Commit `5f38e49b`.
- 2026-04-25 — **`var` hoisting.** Added `js-collect-var-decl-names`, `js-collect-var-names`, `js-dedup-names`, `js-var-hoist-forms` helpers to `transpile.sx`. Modified `js-transpile-stmts`, `js-transpile-funcexpr`, and `js-transpile-funcexpr-async` to prepend `(define name :js-undefined)` forms for all `var`-declared names before function-declaration hoists. Shallow collection (direct statements only). 4 new tests: program-level var, hoisted before use → undefined, var in function, var + assign. 529/530 unit (+4), 148/148 slice unchanged. Commit `11315d91`.
- 2026-04-25 — **ASI (Automatic Semicolon Insertion).** Lexer: added `:nl` (newline-before) boolean to every token dict; `skip-ws!` sets it true when consuming `\n`/`\r`; `scan!` resets it to `false` at the start of each token scan. Parser: new `jp-token-nl?` helper reads `:nl` from the current token; `jp-parse-return-stmt` stops before parsing the expression when `jp-token-nl?` is true (restricted production: `return\nvalue``return undefined`). 4 new tests (flag presence, flag value, restricted return). 525/526 unit (+4), 148/148 slice unchanged. Commit `ae86579a`.
- 2026-04-23 — scaffold landed: lib/js/{lexer,parser,transpile,runtime}.sx stubs + test.sh. 7/7 smoke tests pass (js-tokenize/js-parse/js-transpile stubs + js-to-boolean coercion cases). - 2026-04-23 — scaffold landed: lib/js/{lexer,parser,transpile,runtime}.sx stubs + test.sh. 7/7 smoke tests pass (js-tokenize/js-parse/js-transpile stubs + js-to-boolean coercion cases).
- 2026-04-23 — Phase 1 (Lexer) complete: numbers (int/float/hex/exp/leading-dot), strings (escapes), idents/keywords, punctuation, all operators (1-4 char, longest-match), // and /* */ comments. 38/38 tests pass. Gotchas found: `peek` and `emit!` are primitives (shadowed to `js-peek`, `js-emit!`); `cond` clauses take ONE body only, multi-expr needs `(do ...)` wrapper. - 2026-04-23 — Phase 1 (Lexer) complete: numbers (int/float/hex/exp/leading-dot), strings (escapes), idents/keywords, punctuation, all operators (1-4 char, longest-match), // and /* */ comments. 38/38 tests pass. Gotchas found: `peek` and `emit!` are primitives (shadowed to `js-peek`, `js-emit!`); `cond` clauses take ONE body only, multi-expr needs `(do ...)` wrapper.
- 2026-04-23 — Phase 2 (Pratt expression parser) complete: literals, binary precedence (w/ `**` right-assoc), unary (`- + ! ~ typeof void`), member access (`.`/`[]`), call chains, array/object literals (ident+string+number keys), ternary, arrow fns (zero/one/many params; curried), assignment (right-assoc incl. compound `+=` etc.). AST node shapes all match the `js-*` names already wired. 47 new tests, 85/85 total. Most of the Phase 2 scaffolding was already written in an earlier session — this iteration verified every path, added the parser test suite, and greened everything on the first pass. No new gotchas beyond Phase 1. - 2026-04-23 — Phase 2 (Pratt expression parser) complete: literals, binary precedence (w/ `**` right-assoc), unary (`- + ! ~ typeof void`), member access (`.`/`[]`), call chains, array/object literals (ident+string+number keys), ternary, arrow fns (zero/one/many params; curried), assignment (right-assoc incl. compound `+=` etc.). AST node shapes all match the `js-*` names already wired. 47 new tests, 85/85 total. Most of the Phase 2 scaffolding was already written in an earlier session — this iteration verified every path, added the parser test suite, and greened everything on the first pass. No new gotchas beyond Phase 1.