wcc+w6c+w6c_ww: delete() range form delete(xs[lo:hi]) (fold-5a P2)

Hare's delete also takes a slicing place (harec check.c:1981-2027
EXPR_SLICE; Hare spells it delete(xs[i..j])): remove [lo, hi) — shift
[hi..len) down count = hi-lo strides, len -= count, cap unchanged; lo
defaults 0, hi defaults len, so delete(xs[:]) clears the slice with
storage retained. Checker accepts N_SLICE next to N_INDEX (object must
chase to a slice, harec :2024); the old range-unimplemented reject and
its #35 cite drop.

Lowering (both stages, converged byte-identical by construction) is the
single-element arm's same-slice whole-stride word-copy loop with a
DYNAMIC src offset (count*esz via a src register) instead of the
constant one-stride. Base shapes: local slice ident, deref-of-local,
plus NEW indexed local-slice base xs[g][lo:hi] — the fold-5a consumer
shape (regex.ha:333 delete(jump_idxs[group_level][..]); outer stride
off the type table). Bounds stay implicit, inheriting the documented
single-element posture (no index checks anywhere in cgen). Operands
evaluate left-to-right, exactly once, before the shift (harec order);
only the header ADDRESS is taken before operand eval, so a bound
expression's writes through the slice land before the copy.

test/809: 64 fixtures — full/explicit/re-clear/head/mid/tail/empty
a:a/end-boundary len:len/explicit 0:0 on a never-appended (nil-ptr)
slice, single-vs-range equivalence, cap preservation, esz 1/2/4/8/16/24
copy tails against the dynamic src, operand order-of-eval (lo/hi CALLs
fire once each, in order) + aliasing-visibility pins, the EXACT
[][]size regex consumer shape, deref base, 2 reject rows w/ diagnostic
text; every accept row cs==ww asm byte-id. test/804: reject_range row
retired (form now accepted), reject_nonindex text follows the widened
message.
This commit is contained in:
2026-06-04 23:18:38 +09:00
parent 60e61315bc
commit 1bcf2726cf
9 changed files with 1505 additions and 98 deletions

View File

@@ -17,8 +17,8 @@
* named-alias element cannot mis-stride.
*
* Hare's delete also accepts the range form delete(xs[i..j])
* (ref/harec/src/check.c:1981-2027 EXPR_SLICE). Out of scope here —
* checker loud-rejects it (reject_range row); filed on #35.
* (ref/harec/src/check.c:1981-2027 EXPR_SLICE) — implemented as the
* fold-5a prereq P2; covered by 809_delete_range.
*
* row | shape | want
* ----------------+----------------------------------------+------
@@ -47,9 +47,8 @@
* | iteration, base-4 order accumulation |
* reject_array | delete(t[0]) on [3]i64 — "delete must | BUILD_FAIL
* | operate on a slice" |
* reject_nonindex | delete(xs) — operand must be xs[i] | BUILD_FAIL
* reject_range | delete(xs[0:2]) — range form deferred, | BUILD_FAIL
* | message must cite task #35 |
* reject_nonindex | delete(xs) — operand must be an index- | BUILD_FAIL
* | ing or slicing expression |
* reject_arity | delete(xs[0], xs[1]) | BUILD_FAIL
*
* BUILD_FAIL rows also assert the diagnostic TEXT (stderr substring,
@@ -78,9 +77,9 @@ runwait(const char *cmd)
/* want == BUILD_FAIL: the row must FAIL to build on both stages AND
* emit expect_err on stderr (the checker reject set — message text
* included, esp. the #35 cite on the deferred range form — is part of
* the contract: rule 7, never a silent acceptance; without the message
* check a row would pass vacuously on any unrelated build failure). */
* included — is part of the contract: rule 7, never a silent
* acceptance; without the message check a row would pass vacuously on
* any unrelated build failure). */
#define BUILD_FAIL (-2147483647 - 1)
struct row {
@@ -290,18 +289,7 @@ static const struct row rows[] = {
"\tdelete(xs);\n"
"\treturn 0;\n"
"};\n",
BUILD_FAIL, "delete: operand must be an indexing expression" },
{ "reject_range",
"package main;\n"
"export fn main() i32 = {\n"
"\tlet xs: []u8 = [];\n"
"\tappend(xs, 5u8);\n"
"\tappend(xs, 6u8);\n"
"\tdelete(xs[0:2]);\n"
"\treturn 0;\n"
"};\n",
BUILD_FAIL, "range form delete(xs[i..j]) unimplemented (task #35)" },
BUILD_FAIL, "delete: operand must be an indexing or slicing expression" },
{ "reject_arity",
"package main;\n"