compile-let called scope-define-local eagerly as part of the let binding, adding the new local to the scope before compile-expr ran for the init expression. When nested lets rebound the same variable (e.g. the hyperscript parser's 4 chained `parts` bindings), the init expression resolved the name to the new uninitialized slot instead of the outer one — producing nil where it should have read the previous value. Move scope-define-local after compile-expr so init expressions see the outer scope's binding. Fixes all 11 JIT hyperscript parser failures. 3127/3127 JIT + non-JIT, 25/25 standalone hyperscript tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
13 lines
388 B
Plaintext
13 lines
388 B
Plaintext
;; Minimal test: define-inside-let pattern (like hs-parse)
|
|
(define
|
|
test-closure-parse
|
|
(fn
|
|
(tokens)
|
|
(let
|
|
((p 0) (tok-len (len tokens)))
|
|
(define get-val (fn () (get (nth tokens p) "value")))
|
|
(define advance! (fn () (set! p (+ p 1))))
|
|
(let
|
|
((first-val (get-val)))
|
|
(advance!)
|
|
(list "first:" first-val "second:" (get-val) "p:" p))))) |