From ecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 Mon Sep 17 00:00:00 2001 From: Moon Flower Date: Mon, 12 Oct 2026 08:46:23 +0330 Subject: a --- tests/programs/zc0typed.zc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/programs/zc0typed.zc (limited to 'tests/programs/zc0typed.zc') diff --git a/tests/programs/zc0typed.zc b/tests/programs/zc0typed.zc new file mode 100644 index 0000000..4b7f438 --- /dev/null +++ b/tests/programs/zc0typed.zc @@ -0,0 +1,23 @@ +// the stage 0 compiler (src/tools/zc0.c) has no types. it reads them and throws +// them away, so a typed program and the same program without the types come +// out as the same image. tests/programs/zc0plain.zc is this file with the types off. +int total; +[8]int table; +[]word names; +const int LIMIT = 10; + +int add(int a, int b) { return a + b; } +.u grow([]word v, int n) { return v; } +bool keep(int.d x, .m y) { return x != y; } +int apply(int(int) f, int* p, vec>*.u q) { return f(*p); } +int sq(int x) { return x * x; } + +fn start() { + int i = 0, sum = 0; + [4]int a; + int* p = a; + for (int j = 0; j < LIMIT; j++) sum = add(sum, sq(j)); + while (i < 4) { a[i] = i; i++; } + total = sum + a[3] + table[2]; + return total; +} -- cgit v1.2.3