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); }
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user