From 4559b52950da82fceca5c203656567c6c07299f4 Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Fri, 7 Aug 2026 23:50:02 +0900 Subject: [PATCH] cgen: default the hi bound of an N_DOT array-field slice arg pushargsrev's N_SLICE arm resolved esz and the base address from the stamped tinfo of an N_DOT [N]T-field base but let the omitted hi bound fall to $0, so the #258 array-to-slice borrow desugar handed callees a zero-length slice: base64 clear()'s bytes.zero(e.ibuf) was a runtime no-op under the wwstage frontend. Take the element count from the field's array tinfo like the cgslice #252 arm and cstage's bu->alen. Graduates r989_libprecond_decodedsize_aligned and the 989_lib_byteid #59.3 base64 pin. --- Makefile | 2 +- selfhost/cmd/wcc/cgenutil.ww | 10 +++++++++- test/wcc/989_lib_byteid.c | 4 +++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 4e734798..477bf1d1 100644 --- a/Makefile +++ b/Makefile @@ -586,7 +586,7 @@ DATABYTEID_EXPECTED_MIN = 911 DATABYTEID_DIVERGED = r71_tagged_return_scratch_mixed \ r76_typeeq_fn_diff_arity r76_typeeq_fn_diff_param_type \ r76_typeeq_fn_io_vtable_shape r76_typeeq_fn_variadic_vs_fixed \ - r940_str_forrange_arg r989_libprecond_decodedsize_aligned + r940_str_forrange_arg $(if $(DATABYTEID_FILES),,$(error test-byteid: empty data corpus)) test-data-byteid: $(BIN)/ww $(BIN)/w6c $(BIN)/w6c_ww @work=$$(mktemp -d "$(CURDIR)/$(DATABYTEID_DIR).XXXXXX") || exit 1; \ diff --git a/selfhost/cmd/wcc/cgenutil.ww b/selfhost/cmd/wcc/cgenutil.ww index 8f212b64..82b01803 100644 --- a/selfhost/cmd/wcc/cgenutil.ww +++ b/selfhost/cmd/wcc/cgenutil.ww @@ -774,9 +774,17 @@ fn pushargsrev(c: *cgen, arg: *syntax.node, param: *syntax.node, memphase: bool, emitline("\tMOVQ\t8(CX), AX\n"); };}; }; + } else { if (dotbu != nil && dotbu.kind == syntax.tykind.TY_ARRAY) { + // #252 twin: default-hi over an N_DOT `[N]T`-field base — + // element count from the field's array tinfo (cstage reads + // bu->alen uniformly). Without this the #258 array→slice + // borrow desugar handed callees a 0-length slice. + emitline("\tMOVQ\t$"); + emitint(dotbu.alen: i64); + emitline(", AX\n"); } else { emitline("\tMOVQ\t$0, AX\n"); - };};}; + };};};}; emitline("\tPUSHQ\tAX\n"); // lo (default 0) → AX if (lo != nil) { cgexpr(c, lo); } diff --git a/test/wcc/989_lib_byteid.c b/test/wcc/989_lib_byteid.c index db9c227d..84b5fc49 100644 --- a/test/wcc/989_lib_byteid.c +++ b/test/wcc/989_lib_byteid.c @@ -145,8 +145,10 @@ static const struct ent ents[] = { { .fixture = "lib/ascii/asciitest.ww", .mode = M_ID, .cite = "#59.1 graduated by #146 str==" }, /* #59.2 bufio graduated to M_ID above (#129 fix) */ + /* #59.3 base64 graduated to M_ID (pushargsrev N_DOT array-field + * default-hi fix — clear()'s borrow no longer zero-length) */ { .fixture = "lib/encoding/base64/base64_test.ww", - .mode = M_DIVERGE, .cite = "#59.3" }, + .mode = M_ID }, /* #59.4 hextest graduated to M_ID above (#22a reviewer fixes) */ { .fixture = "lib/errors/errnotest.ww", .mode = M_DIVERGE, .cite = "#59.5" },