x.slicefield[:] / x.strfield[2:] emitted MOVQ $0 for the omitted hi
bound on BOTH stages (N_IDENT-gated dispatch; symmetric, so byte
identity never caught it) in all four sites: cgexpr N_SLICE + pushargs
(cstage), cgslice + pushargsrev (wwstage). The new arm re-evaluates
the pure field read for its {ptr,len,cap} header and takes .len,
covering local, viaptr, dot-chain, (*p), arr[i], and global inners.
Call inners still loud-reject upstream. Sibling of the #252/#257
array-field arms.
50 lines
1.4 KiB
Plaintext
50 lines
1.4 KiB
Plaintext
//ww:run
|
|
// Default-hi slice of a slice/str FIELD (`x.f[:]`, `x.f[2:]`) —
|
|
// expression position. The pre-fix default-hi dispatch was
|
|
// N_IDENT-gated on BOTH stages, so an N_DOT base fell to MOVQ $0
|
|
// (len 0 / negative, byteid-blind). Covers local, viaptr, dot-chain,
|
|
// (*p) spelling, and struct-array-element inners.
|
|
package main;
|
|
|
|
type inner = struct {
|
|
buf: []i32,
|
|
name: str,
|
|
};
|
|
|
|
type outer = struct {
|
|
pad: i64,
|
|
in: inner,
|
|
};
|
|
|
|
export fn main() int = {
|
|
let arr: [4]i32 = [10, 20, 30, 40];
|
|
let v: inner = inner{ buf = arr[:], name = "hello" };
|
|
let b1: []i32 = v.buf[:];
|
|
if (len(b1) != 4) { return 1; };
|
|
let b2: []i32 = v.buf[1:];
|
|
if (len(b2) != 3) { return 2; };
|
|
if (b2[0] != 20) { return 3; };
|
|
let s1: str = v.name[2:];
|
|
if (len(s1) != 3) { return 4; };
|
|
let p: *inner = &v;
|
|
let b3: []i32 = p.buf[:];
|
|
if (len(b3) != 4) { return 5; };
|
|
let s2: str = p.name[1:];
|
|
if (len(s2) != 4) { return 6; };
|
|
let o: outer = outer{ pad = 7, in = inner{ buf = arr[:], name = "world" } };
|
|
let b4: []i32 = o.in.buf[:];
|
|
if (len(b4) != 4) { return 7; };
|
|
let b5: []i32 = o.in.buf[2:];
|
|
if (len(b5) != 2) { return 8; };
|
|
if (b5[1] != 40) { return 9; };
|
|
let s3: str = o.in.name[3:];
|
|
if (len(s3) != 2) { return 10; };
|
|
let b6: []i32 = (*p).buf[:];
|
|
if (len(b6) != 4) { return 11; };
|
|
let xs: [2]inner = [v, v];
|
|
let b7: []i32 = xs[1].buf[:];
|
|
if (len(b7) != 4) { return 12; };
|
|
if (b7[3] != 40) { return 13; };
|
|
return 0;
|
|
};
|