F2.2: un-workaround 0714 — combine string == under and/or (0078 fixed)
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.
This commit is contained in:
@@ -30,13 +30,9 @@ report :: (label: string, ok: bool) {
|
|||||||
if ok { print("{}: ok\n", label); } else { print("{}: FAIL\n", label); }
|
if ok { print("{}: ok\n", label); } else { print("{}: FAIL\n", label); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Half-open containment [lo, hi). Written with early returns (no `and`) so
|
// Half-open containment [lo, hi).
|
||||||
// the assertions below never combine comparisons with short-circuit
|
|
||||||
// `and`/`or` — see issues/0078.
|
|
||||||
in_range :: (x: s64, lo: s64, hi: s64) -> bool {
|
in_range :: (x: s64, lo: s64, hi: s64) -> bool {
|
||||||
if x < lo { return false; }
|
return x >= lo and x < hi;
|
||||||
if x >= hi { return false; }
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// True when `parse(src)` raised `want` — destructure captures the error
|
// 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; };
|
is_null := if o.items[4].val == { case .null_: true; else: false; };
|
||||||
report("null-value", is_null);
|
report("null-value", is_null);
|
||||||
|
|
||||||
// Two separate reports (not `key=="k" and val=="v"`): a string `==`
|
// The nested pair asserted as one expression — a string `==` on each
|
||||||
// as an operand of short-circuit `and`/`or` miscompiles — see
|
// side of `and`.
|
||||||
// issues/0078. Every assertion here is therefore a single comparison.
|
|
||||||
sub := o.items[5].val.object;
|
sub := o.items[5].val.object;
|
||||||
report("nested-key", sub.items[0].key == "k");
|
report("nested-pair", sub.items[0].key == "k" and sub.items[0].val.str == "v");
|
||||||
report("nested-val", sub.items[0].val.str == "v");
|
|
||||||
|
|
||||||
// ── 2. Heap discipline: view vs decoded ──────────────────────────
|
// ── 2. Heap discipline: view vs decoded ──────────────────────────
|
||||||
base : s64 = xx src.ptr;
|
base : s64 = xx src.ptr;
|
||||||
@@ -96,7 +90,6 @@ main :: () -> ! {
|
|||||||
report("round-trip", rt == src);
|
report("round-trip", rt == src);
|
||||||
|
|
||||||
// ── 4. Leading/trailing/inner whitespace is insignificant ────────
|
// ── 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);
|
wsv := try parse(" [ 1 , 2 , 3 ] ", xx arena);
|
||||||
wa := wsv.array;
|
wa := wsv.array;
|
||||||
report("ws-count", wa.len == 3);
|
report("ws-count", wa.len == 3);
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ array-pos: ok
|
|||||||
array-neg: ok
|
array-neg: ok
|
||||||
bool-value: ok
|
bool-value: ok
|
||||||
null-value: ok
|
null-value: ok
|
||||||
nested-key: ok
|
nested-pair: ok
|
||||||
nested-val: ok
|
|
||||||
plain-is-view: ok
|
plain-is-view: ok
|
||||||
escaped-allocated: ok
|
escaped-allocated: ok
|
||||||
round-trip: ok
|
round-trip: ok
|
||||||
|
|||||||
Reference in New Issue
Block a user