From 301e966bcf493c75b189b602ad3fc2fc86413903 Mon Sep 17 00:00:00 2001 From: agra Date: Thu, 4 Jun 2026 02:17:22 +0300 Subject: [PATCH] =?UTF-8?q?F2.2:=20un-workaround=200714=20=E2=80=94=20comb?= =?UTF-8?q?ine=20string=20=3D=3D=20under=20and/or=20(0078=20fixed)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue 0078 (string == as an and/or operand emitting an invalid PHI) is resolved on this branch, so the example no longer needs the split that worked around it. Restore the natural combined assertion sub.items[0].key == "k" and sub.items[0].val.str == "v" (one nested-pair report), and the in_range containment helper to return x >= lo and x < hi; Drop the now-stale issues/0078 references. Re-captured expected stdout (nested-key/nested-val -> nested-pair). json.sx and src/ untouched. --- examples/0714-modules-json-reader.sx | 17 +++++------------ .../expected/0714-modules-json-reader.stdout | 3 +-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/examples/0714-modules-json-reader.sx b/examples/0714-modules-json-reader.sx index 2197638..f7e1b79 100644 --- a/examples/0714-modules-json-reader.sx +++ b/examples/0714-modules-json-reader.sx @@ -30,13 +30,9 @@ report :: (label: string, ok: bool) { if ok { print("{}: ok\n", label); } else { print("{}: FAIL\n", label); } } -// Half-open containment [lo, hi). Written with early returns (no `and`) so -// the assertions below never combine comparisons with short-circuit -// `and`/`or` — see issues/0078. +// Half-open containment [lo, hi). in_range :: (x: s64, lo: s64, hi: s64) -> bool { - if x < lo { return false; } - if x >= hi { return false; } - return true; + return x >= lo and x < hi; } // True when `parse(src)` raised `want` — destructure captures the error @@ -74,12 +70,10 @@ main :: () -> ! { is_null := if o.items[4].val == { case .null_: true; else: false; }; report("null-value", is_null); - // Two separate reports (not `key=="k" and val=="v"`): a string `==` - // as an operand of short-circuit `and`/`or` miscompiles — see - // issues/0078. Every assertion here is therefore a single comparison. + // The nested pair asserted as one expression — a string `==` on each + // side of `and`. sub := o.items[5].val.object; - report("nested-key", sub.items[0].key == "k"); - report("nested-val", sub.items[0].val.str == "v"); + report("nested-pair", sub.items[0].key == "k" and sub.items[0].val.str == "v"); // ── 2. Heap discipline: view vs decoded ────────────────────────── base : s64 = xx src.ptr; @@ -96,7 +90,6 @@ main :: () -> ! { report("round-trip", rt == src); // ── 4. Leading/trailing/inner whitespace is insignificant ──────── - // Each comparison is its own report (no `and`-combining — issues/0078). wsv := try parse(" [ 1 , 2 , 3 ] ", xx arena); wa := wsv.array; report("ws-count", wa.len == 3); diff --git a/examples/expected/0714-modules-json-reader.stdout b/examples/expected/0714-modules-json-reader.stdout index 796b0a9..fb03da7 100644 --- a/examples/expected/0714-modules-json-reader.stdout +++ b/examples/expected/0714-modules-json-reader.stdout @@ -8,8 +8,7 @@ array-pos: ok array-neg: ok bool-value: ok null-value: ok -nested-key: ok -nested-val: ok +nested-pair: ok plain-is-view: ok escaped-allocated: ok round-trip: ok