diff options
| author | 2026-10-14 16:38:21 +0330 | |
|---|---|---|
| committer | 2026-10-14 16:38:21 +0330 | |
| commit | 3dd842d6e8ccafce954b9c72346f2cfefc9e31d5 (patch) | |
| tree | 5092c4220d0c9dbb660a4d610d889e5a55294cf6 /tests | |
| parent | Revert "zc0: read integer literals like the compiler: decimal with leading ze... (diff) | |
zc0umd: no recast uses a visible u/m/d as its tag (spec 1.6.3); spec: the fixed appendix b bugs are marked fixed
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/programs/zc0umd.zc | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/tests/programs/zc0umd.zc b/tests/programs/zc0umd.zc index 9693111..b5a6d2a 100644 --- a/tests/programs/zc0umd.zc +++ b/tests/programs/zc0umd.zc @@ -2,12 +2,13 @@ namespace; include rt; // u, m and d are ordinary names, and a tag is written .u, .m or .d after a type. -// u*x, m*x and d*x with no space before the star is a recast, and u * x with a -// space is a product. the same program runs on the resident compiler and, built +// u*x, m*x and d*x with no space before the star is a recast when no variable +// named u, m or d is visible there (spec 1.6.3); otherwise, and with a space, it +// is a product. the same program runs on the resident compiler and, built // into a run-only image, on stage 0 (src/tools/zc0.c), which reads the tags and // recasts and does nothing with them. -int u = 2, m = 3; // globals +int uu = 2, m = 3; // globals (no global u, so u*x recasts below; m*x with m visible is a product) int[4] d4; int d(int x) { return x + 1; } // a function @@ -17,12 +18,12 @@ int tagged(int(int) f, int.m x) { return f(x); } // owned objects through locals named for their tags word*.u box(int v) { word* m = rt.new(2); m[0] = v; m[1] = v * 2; return u*m; } -word*.u pair(int u, int m) { +word*.u pair(int x, int m) { word* d = rt.new(2); - d[0] = u; d[1] = m; + d[0] = x; d[1] = m; return u*d; } -.u single(int v) { let u = rt.new(1); u[0] = v; return u*u; } +.u single(int v) { let d = rt.new(1); d[0] = v; return u*d; } int sum(word*.m m) { return m[0] + m[1]; } int eat(word*.d d) { return d[0] + d[1]; } int hold(.m u, .d d) { return u[0] * 100 + d[0]; } @@ -35,9 +36,9 @@ fn main() { .m q = single(6); word* r = pair(8, 9); let c = box(10), e = pair(1, 2); - rt.put_n(u * m); rt.put_c(32); // two globals multiplied - rt.put_n(u*=m); rt.put_c(32); // u *= m is not a recast either - rt.put_n(d(u) * d(m)); rt.put_c(32); + rt.put_n(uu * m); rt.put_c(32); // two globals multiplied + rt.put_n(uu*=m); rt.put_c(32); // *= is not a recast either + rt.put_n(d(uu) * d(m)); rt.put_c(32); rt.put_n(mul3(2, 3, 4)); rt.put_c(32); rt.put_n(mixed(7, 6, 5)); rt.put_c(32); rt.put_n(tagged(d, n)); rt.put_c(10); |
