diff options
| author | 2026-10-14 08:30:01 +0000 | |
|---|---|---|
| committer | 2026-10-14 08:30:01 +0000 | |
| commit | d274751e89f75cc0f0e25c6e5e87ef91b64597ee (patch) | |
| tree | ef76f2cfe9d2a09f3fe5d27278cf775649bc162f /tests/programs | |
| parent | lsp: quick fixes for hints and bare library names; comment cleanup (diff) | |
zc: untyped local const, c precedence for && and ||, import fixes for every module
const name = value; inside a function declares a local constant that takes
the initializer's type. the let quick fix now writes a bare const.
the self-hosted compiler bound || tighter than &&, unlike zc0 and the
readme. no existing source mixed them without parentheses, so only new
code was affected.
missing-name diagnostics and their quick fixes now search every module:
rt, core, run, loaded files, and std, icon and actor scanned from source,
including static groups (std.Text.itoa). typos suggest module exports
(putc -> rt.put_c) and get a change-to fix.
Diffstat (limited to 'tests/programs')
| -rw-r--r-- | tests/programs/const_local.zc | 11 | ||||
| -rw-r--r-- | tests/programs/precedence.zc | 13 |
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/programs/const_local.zc b/tests/programs/const_local.zc new file mode 100644 index 0000000..83c423c --- /dev/null +++ b/tests/programs/const_local.zc @@ -0,0 +1,11 @@ +// a local const without a type takes its initializer's type and can't be written. +include rt; +fn main() { + const k = 6, j = k * 7; + const half = 2.5; + const name = "zc"; + int typed = j; + rt.put_n(k); rt.put_c(32); rt.put_n(typed); rt.put_c(32); + if (half > 2.0) rt.put_s(name); + rt.put_c(10); +} diff --git a/tests/programs/precedence.zc b/tests/programs/precedence.zc new file mode 100644 index 0000000..18b323d --- /dev/null +++ b/tests/programs/precedence.zc @@ -0,0 +1,13 @@ +// && binds tighter than ||, and both bind below the comparisons and |, as in c. +include rt; +int calls; +int seen(int v) { calls++; return v; } +fn main() { + int t = 1, f = 0; + rt.put_n(f && t || t); rt.put_c(32); // (f && t) || t is 1; f && (t || t) would be 0 + rt.put_n(t || t && f); rt.put_c(32); // t || (t && f) is 1 + rt.put_n(f && f || t && t); rt.put_c(32); + rt.put_n(1 | 0 && 2 == 2); rt.put_c(32); + calls = 0; int r = seen(1) || seen(0) && seen(1); + rt.put_n(r); rt.put_c(32); rt.put_n(calls); rt.put_c(10); // || stops after the first call +} |
