HS: skip element/global/local scope prefix in set — +3 core/scoping
`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) <noreply@anthropic.com>
This commit is contained in:
@@ -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)))
|
||||
|
||||
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user