From 4fe0b649650cf18b6cc757e10429432e388c5226 Mon Sep 17 00:00:00 2001 From: giles Date: Thu, 23 Apr 2026 21:40:00 +0000 Subject: [PATCH] HS: not precedence over or + truthy/falsy coercion (+3 tests) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit parse-atom emitted (not (parse-expr)) which let or/and capture the whole RHS before `not` could bind. Also emitted SX `not` which treats only nil/ false as falsy, so `not 0` returned false. Fix: `not` now emits `(hs-falsy? (parse-atom))` — tight binding to the following atom, and hyperscript-style truthy/falsy (0, "", nil, false, []). 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 4cde77ee..9723d9a3 100644 --- a/lib/hyperscript/parser.sx +++ b/lib/hyperscript/parser.sx @@ -137,7 +137,7 @@ (when (and (= (tp-type) "op") (= (tp-val) "!")) (adv!)) (list (quote beep!) (parse-expr)))) ((and (= typ "keyword") (= val "not")) - (do (adv!) (list (quote not) (parse-expr)))) + (do (adv!) (list (quote hs-falsy?) (parse-atom)))) ((and (= typ "keyword") (= val "no")) (do (adv!) (list (quote no) (parse-expr)))) ((and (= typ "keyword") (= val "eval")) diff --git a/shared/static/wasm/sx/hs-parser.sx b/shared/static/wasm/sx/hs-parser.sx index 4cde77ee..9723d9a3 100644 --- a/shared/static/wasm/sx/hs-parser.sx +++ b/shared/static/wasm/sx/hs-parser.sx @@ -137,7 +137,7 @@ (when (and (= (tp-type) "op") (= (tp-val) "!")) (adv!)) (list (quote beep!) (parse-expr)))) ((and (= typ "keyword") (= val "not")) - (do (adv!) (list (quote not) (parse-expr)))) + (do (adv!) (list (quote hs-falsy?) (parse-atom)))) ((and (= typ "keyword") (= val "no")) (do (adv!) (list (quote no) (parse-expr)))) ((and (= typ "keyword") (= val "eval"))