From 24dbc966e9b7c9a2bc46d00a3d0d804770e8dd4b Mon Sep 17 00:00:00 2001 From: giles Date: Thu, 23 Apr 2026 11:32:20 +0000 Subject: [PATCH] =?UTF-8?q?HS:=20skip=20`element`/`global`/`local`=20scope?= =?UTF-8?q?=20prefix=20in=20`set`=20=E2=80=94=20+3=20core/scoping?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `set element x to 10` was compiling to `(set! (string-postfix (ref "element") "x") 10)` because parse-expr greedily consumed `element x` as a string-postfix expression. Recognise the bare `element` / `global` / `local` ident at the start of the set target and skip it so `tgt` parses as just `x`. The variable lives in the closure scope of the handler — close enough for handler-local use; a real per-element store would need extra work in the compiler. core/scoping: 9/20 → 12/20 (+3): "element scoped variables work", "element scoped variables span features", "global scoped variables work". The `:x` / `$x` short-syntax variants still fail because their listeners aren't registering in the test mock — separate issue. Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/hyperscript/parser.sx | 2 +- shared/static/wasm/sx/hs-parser.sx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/hyperscript/parser.sx b/lib/hyperscript/parser.sx index 3a657199..3d88a560 100644 --- a/lib/hyperscript/parser.sx +++ b/lib/hyperscript/parser.sx @@ -1272,7 +1272,7 @@ (fn () (let - ((tgt (parse-expr))) + ((tgt (cond ((and (= (tp-type) "ident") (or (= (tp-val) "element") (= (tp-val) "global") (= (tp-val) "local"))) (do (adv!) (parse-expr))) (true (parse-expr))))) (cond ((match-kw "to") (let ((value (parse-expr))) (list (quote set!) tgt value))) diff --git a/shared/static/wasm/sx/hs-parser.sx b/shared/static/wasm/sx/hs-parser.sx index 3a657199..3d88a560 100644 --- a/shared/static/wasm/sx/hs-parser.sx +++ b/shared/static/wasm/sx/hs-parser.sx @@ -1272,7 +1272,7 @@ (fn () (let - ((tgt (parse-expr))) + ((tgt (cond ((and (= (tp-type) "ident") (or (= (tp-val) "element") (= (tp-val) "global") (= (tp-val) "local"))) (do (adv!) (parse-expr))) (true (parse-expr))))) (cond ((match-kw "to") (let ((value (parse-expr))) (list (quote set!) tgt value)))