Add sibling sublist parser tests + reset JIT sx-parse
Tests: parse "(a (b) (c))" must produce 3 siblings, not nested. Catches JIT compilation bug where closing parens cause sibling lists to become children. Reset sx-parse to CEK on the OCaml kernel — the JIT-compiled version of sx-parse's complex letrec produces wrong bytecode. CEK interpretation works correctly (tests pass on all platforms). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -440,6 +440,16 @@ class OcamlBridge:
|
|||||||
_logger.warning("OCaml load skipped %s: %s",
|
_logger.warning("OCaml load skipped %s: %s",
|
||||||
filepath, e)
|
filepath, e)
|
||||||
|
|
||||||
|
# JIT workaround: sx-parse has a complex letrec (20 mutually
|
||||||
|
# recursive functions) that the JIT compiles incorrectly —
|
||||||
|
# closing parens cause siblings to become children.
|
||||||
|
# CEK-interpreted sx-parse works correctly.
|
||||||
|
try:
|
||||||
|
await self._send('(vm-reset-fn "sx-parse")')
|
||||||
|
await self._read_until_ok(ctx=None)
|
||||||
|
except OcamlBridgeError:
|
||||||
|
pass
|
||||||
|
|
||||||
# SSR overrides: effect is a no-op on the server (prevents
|
# SSR overrides: effect is a no-op on the server (prevents
|
||||||
# reactive loops during island SSR — effects are DOM side-effects)
|
# reactive loops during island SSR — effects are DOM side-effects)
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -79,6 +79,19 @@
|
|||||||
(assert-length 1 result)
|
(assert-length 1 result)
|
||||||
(assert-equal (list 1 (list 2 3) 4) (first result))))
|
(assert-equal (list 1 (list 2 3) 4) (first result))))
|
||||||
|
|
||||||
|
(deftest "parse sibling sublists"
|
||||||
|
;; Regression: closing paren of (b) must not swallow (c) as a child
|
||||||
|
(let ((result (sx-parse "(a (b) (c))")))
|
||||||
|
(assert-length 1 result)
|
||||||
|
(assert-length 3 (first result))
|
||||||
|
(assert-equal (list (make-symbol "a") (list (make-symbol "b")) (list (make-symbol "c")))
|
||||||
|
(first result))))
|
||||||
|
|
||||||
|
(deftest "parse multiple sibling sublists with content"
|
||||||
|
(let ((result (sx-parse "(div (span 1) (span 2) (span 3))")))
|
||||||
|
(assert-length 1 result)
|
||||||
|
(assert-length 4 (first result))))
|
||||||
|
|
||||||
(deftest "parse square brackets as list"
|
(deftest "parse square brackets as list"
|
||||||
(let ((result (sx-parse "[1 2 3]")))
|
(let ((result (sx-parse "[1 2 3]")))
|
||||||
(assert-length 1 result)
|
(assert-length 1 result)
|
||||||
|
|||||||
Reference in New Issue
Block a user