From 280c12c630d882410def0a89145f9d07c1174a1e Mon Sep 17 00:00:00 2001 From: agra Date: Thu, 28 May 2026 12:14:52 +0300 Subject: [PATCH] issues: promote 6 fixed bug repros to focused regression tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All six produce their target outputs cleanly today; renamed out of the `issue-*` namespace per CLAUDE.md "Resolving an open issue": | Old | New | |----------------------|-------------------------------------------| | issue-0032 | 181-impl-duplicate-same-file | | issue-0041 | 182-compound-type-in-expression | | issue-0042 | 183-type-alias-size-align | | issue-0044 | 184-objc-defined-class-method-self | | issue-0045 | 185-pack-fn-comptime-return | | issue-0046 | 186-nested-comptime-return | Comment headers tightened to feature-focused (drop the issue-NNNN provenance — that's in git history now). Missing expected `.txt` / `.exit` files captured for 0041 + 0042 (they were untracked because the bugs were fixed silently in adjacent work). `examples/issue-*` after this commit: just `issue-0030.sx` — a feature request (`extern G : T;` cross-file globals) that's never been implemented. Staying in the issue namespace as a parked proposal until the feature lands or gets formally rejected. 220/220 example tests + `zig build test` green. --- examples/181-impl-duplicate-same-file.sx | 19 ++++++++++++++++ ....sx => 182-compound-type-in-expression.sx} | 7 ++++-- ...e-0042.sx => 183-type-alias-size-align.sx} | 10 ++++----- ... => 184-objc-defined-class-method-self.sx} | 22 +++++++++---------- ...0045.sx => 185-pack-fn-comptime-return.sx} | 9 +++++--- ...-0046.sx => 186-nested-comptime-return.sx} | 15 +++++++------ examples/issue-0032.sx | 17 -------------- ...exit => 181-impl-duplicate-same-file.exit} | 0 .../expected/181-impl-duplicate-same-file.txt | 1 + ...t => 182-compound-type-in-expression.exit} | 0 .../182-compound-type-in-expression.txt | 10 +++++++++ ...45.exit => 183-type-alias-size-align.exit} | 0 tests/expected/183-type-alias-size-align.txt | 7 ++++++ ...> 184-objc-defined-class-method-self.exit} | 0 ...=> 184-objc-defined-class-method-self.txt} | 0 .../expected/185-pack-fn-comptime-return.exit | 1 + ...45.txt => 185-pack-fn-comptime-return.txt} | 0 .../expected/186-nested-comptime-return.exit | 1 + ...046.txt => 186-nested-comptime-return.txt} | 0 tests/expected/issue-0032.txt | 1 - 20 files changed, 73 insertions(+), 47 deletions(-) create mode 100644 examples/181-impl-duplicate-same-file.sx rename examples/{issue-0041.sx => 182-compound-type-in-expression.sx} (73%) rename examples/{issue-0042.sx => 183-type-alias-size-align.sx} (60%) rename examples/{issue-0044.sx => 184-objc-defined-class-method-self.sx} (81%) rename examples/{issue-0045.sx => 185-pack-fn-comptime-return.sx} (66%) rename examples/{issue-0046.sx => 186-nested-comptime-return.sx} (57%) delete mode 100644 examples/issue-0032.sx rename tests/expected/{issue-0032.exit => 181-impl-duplicate-same-file.exit} (100%) create mode 100644 tests/expected/181-impl-duplicate-same-file.txt rename tests/expected/{issue-0044.exit => 182-compound-type-in-expression.exit} (100%) create mode 100644 tests/expected/182-compound-type-in-expression.txt rename tests/expected/{issue-0045.exit => 183-type-alias-size-align.exit} (100%) create mode 100644 tests/expected/183-type-alias-size-align.txt rename tests/expected/{issue-0046.exit => 184-objc-defined-class-method-self.exit} (100%) rename tests/expected/{issue-0044.txt => 184-objc-defined-class-method-self.txt} (100%) create mode 100644 tests/expected/185-pack-fn-comptime-return.exit rename tests/expected/{issue-0045.txt => 185-pack-fn-comptime-return.txt} (100%) create mode 100644 tests/expected/186-nested-comptime-return.exit rename tests/expected/{issue-0046.txt => 186-nested-comptime-return.txt} (100%) delete mode 100644 tests/expected/issue-0032.txt diff --git a/examples/181-impl-duplicate-same-file.sx b/examples/181-impl-duplicate-same-file.sx new file mode 100644 index 0000000..1f0f09b --- /dev/null +++ b/examples/181-impl-duplicate-same-file.sx @@ -0,0 +1,19 @@ +// Duplicate impl detection (same-file) — two `impl Into(MyA) for s64` +// declarations in the same file produce a "duplicate impl" diagnostic +// at registration time, not silently shadow one with the other. Sibling +// case to `examples/180-impl-duplicate.sx` which covers the +// cross-module variant. + +#import "modules/std.sx"; + +MyA :: struct { v: s64 = 0; } + +impl Into(MyA) for s64 { + convert :: (self: s64) -> MyA { .{ v = self }; } +} + +impl Into(MyA) for s64 { + convert :: (self: s64) -> MyA { .{ v = self * 2 }; } +} + +main :: () -> s32 { 0; } diff --git a/examples/issue-0041.sx b/examples/182-compound-type-in-expression.sx similarity index 73% rename from examples/issue-0041.sx rename to examples/182-compound-type-in-expression.sx index 717a92c..c82035b 100644 --- a/examples/issue-0041.sx +++ b/examples/182-compound-type-in-expression.sx @@ -1,5 +1,8 @@ -// issue-0041 — Pointer / optional / array / function / tuple types as -// expression-position values (size_of / align_of arg, const-decl RHS). +// Compound type literals in expression position — `size_of` / +// `align_of` accept pointer (`*T`), optional (`?T`), array (`[N]T`), +// function (`(A) -> B`), and tuple (`(A, B)`) types directly. Also +// const-decl RHS aliases through the same forms (`Ptr :: *u8;` etc). +// Same shape as the existing `size_of(s32)` baseline path. #import "modules/std.sx"; diff --git a/examples/issue-0042.sx b/examples/183-type-alias-size-align.sx similarity index 60% rename from examples/issue-0042.sx rename to examples/183-type-alias-size-align.sx index 424503c..ac214a7 100644 --- a/examples/issue-0042.sx +++ b/examples/183-type-alias-size-align.sx @@ -1,8 +1,8 @@ -// issue-0042 — const-decl type alias must resolve through -// `type_alias_map` when used as a `$T: Type` argument to size_of / -// align_of, not silently fall back to .s64 (8 bytes). -// Also covers identifier-RHS aliases (chains + struct aliases), -// not just *T / [N]T / ?T forms. +// Type alias resolution through `size_of` / `align_of` — a const-decl +// alias (`MyInt :: s32;`, `MyChain :: MyInt;`, `WideAlias :: Wide;`) +// resolves through `type_alias_map` when used as a `$T: Type` argument. +// Covers chains and struct-name aliases, not just structural-type +// aliases (those land in `examples/182-compound-type-in-expression.sx`). #import "modules/std.sx"; MyInt :: s32; diff --git a/examples/issue-0044.sx b/examples/184-objc-defined-class-method-self.sx similarity index 81% rename from examples/issue-0044.sx rename to examples/184-objc-defined-class-method-self.sx index 0190dbd..e209a87 100644 --- a/examples/issue-0044.sx +++ b/examples/184-objc-defined-class-method-self.sx @@ -1,15 +1,13 @@ -// issue-0044 — `xx this` inside a BOOL-returning #objc_class method -// truncated to i8 when used as an argument to a foreign-class method -// call. Root cause was resolveCallParamTypes returning an empty slice -// for foreign-class method receivers (the type was a `#foreign -// #objc_class` alias), so the per-arg target_type defaulted to the -// enclosing function's return type (BOOL → i8) and the `xx ptr` cast -// silently truncated the pointer to its low byte. -// -// Verification: every probe must round-trip the receiver pointer. A -// pre-fix compiler reads the LOW BYTE of `xx this` at the -// `addObserver:selector:name:object:` call site, so the observer -// would be e.g. 0xC0/0x20 instead of the real pointer. +// `xx self` inside a BOOL-returning `#objc_class` method must +// resolve to the full receiver pointer at a foreign-class method +// call site, not get truncated to i8 by the enclosing function's +// BOOL return type. Regression locks in the +// `resolveCallParamTypes` fix that threads foreign-class method +// param types correctly even when the receiver is a `#foreign +// #objc_class` alias. Every probe round-trips the receiver pointer +// — a regression would read only the low byte and the observer +// pointer would appear as e.g. 0xC0 / 0x20 instead of its real +// 64-bit value. #import "modules/std.sx"; #import "modules/std/objc.sx"; #import "modules/compiler.sx"; diff --git a/examples/issue-0045.sx b/examples/185-pack-fn-comptime-return.sx similarity index 66% rename from examples/issue-0045.sx rename to examples/185-pack-fn-comptime-return.sx index 4ac4771..4f849f1 100644 --- a/examples/issue-0045.sx +++ b/examples/185-pack-fn-comptime-return.sx @@ -1,6 +1,9 @@ -// issue-0045 — calling a comptime fn whose body is a block -// containing an explicit `return X;` trips LLVM's "Terminator found -// in the middle of a basic block" verifier. +// Pack-fn (or any comptime-param fn) with a block body containing +// an explicit `return X;` lowers to clean IR — the inline-return +// path stores into a dedicated result slot and branches to the +// shared `ret_done` block instead of emitting a `ret` inside the +// caller's basic block. Without that, LLVM's verifier rejected the +// IR with "Terminator found in the middle of a basic block". // // Surfaced by the variadic heterogeneous type packs feature (step // 1 made `..$args` parseable, so the simplest pack-fn smoke test diff --git a/examples/issue-0046.sx b/examples/186-nested-comptime-return.sx similarity index 57% rename from examples/issue-0046.sx rename to examples/186-nested-comptime-return.sx index e3b99c0..2bfaeb1 100644 --- a/examples/issue-0046.sx +++ b/examples/186-nested-comptime-return.sx @@ -1,10 +1,11 @@ -// issue-0046 — nested comptime call + return: state leak from -// outer `lowerComptimeCall` into the wrapper fn built by -// `createComptimeFunction`. Without saving/restoring -// `inline_return_target`, the wrapper inherits an inline-return -// slot belonging to a different basic block; the interp executes -// the wrapper and trips a null-pointer store at -// `storeAtRawPtr`. +// Nested comptime call + return — a comptime fn (`$x: s32`) whose +// body contains BOTH a nested comptime call (`print`) AND a +// `return X;` statement must lower cleanly. The wrapper fn built +// by `createComptimeFunction` saves/restores `inline_return_target` +// so it doesn't inherit a slot belonging to the OUTER caller's +// basic block. Pre-fix: interp executed the wrapper with a +// stale-frame inline-return slot and tripped a null-pointer store +// at `storeAtRawPtr`. // // Repro: comptime fn (`$x: s32`) whose body has BOTH a nested // comptime call (`print`) AND a `return X;` statement. Pre-fix: diff --git a/examples/issue-0032.sx b/examples/issue-0032.sx deleted file mode 100644 index ecde6cb..0000000 --- a/examples/issue-0032.sx +++ /dev/null @@ -1,17 +0,0 @@ -// Phase 2 verification: two impls for the same parameterised-protocol -// (Source, Target) pair declared in the same file MUST produce a clean -// "duplicate impl" diagnostic at registration time. - -#import "modules/std.sx"; - -MyA :: struct { v: s64 = 0; } - -impl Into(MyA) for s64 { - convert :: (self: s64) -> MyA { .{ v = self }; } -} - -impl Into(MyA) for s64 { - convert :: (self: s64) -> MyA { .{ v = self * 2 }; } -} - -main :: () -> s32 { 0; } diff --git a/tests/expected/issue-0032.exit b/tests/expected/181-impl-duplicate-same-file.exit similarity index 100% rename from tests/expected/issue-0032.exit rename to tests/expected/181-impl-duplicate-same-file.exit diff --git a/tests/expected/181-impl-duplicate-same-file.txt b/tests/expected/181-impl-duplicate-same-file.txt new file mode 100644 index 0000000..8ea1db9 --- /dev/null +++ b/tests/expected/181-impl-duplicate-same-file.txt @@ -0,0 +1 @@ +/Users/agra/projects/sx/examples/181-impl-duplicate-same-file.sx:15:1: error: duplicate impl 'Into' for source 's64' in /Users/agra/projects/sx/examples/181-impl-duplicate-same-file.sx diff --git a/tests/expected/issue-0044.exit b/tests/expected/182-compound-type-in-expression.exit similarity index 100% rename from tests/expected/issue-0044.exit rename to tests/expected/182-compound-type-in-expression.exit diff --git a/tests/expected/182-compound-type-in-expression.txt b/tests/expected/182-compound-type-in-expression.txt new file mode 100644 index 0000000..93b896c --- /dev/null +++ b/tests/expected/182-compound-type-in-expression.txt @@ -0,0 +1,10 @@ +size_of(*u8) = 8 +align_of(*u8) = 8 +size_of(?u8) = 2 +size_of([3]u8) = 3 +size_of((s32)->s32) = 8 +size_of((s32, s32)) = 8 +size_of(Ptr) = 8 +size_of(Maybe) = 2 +size_of(Arr) = 3 +size_of(Cb) = 8 diff --git a/tests/expected/issue-0045.exit b/tests/expected/183-type-alias-size-align.exit similarity index 100% rename from tests/expected/issue-0045.exit rename to tests/expected/183-type-alias-size-align.exit diff --git a/tests/expected/183-type-alias-size-align.txt b/tests/expected/183-type-alias-size-align.txt new file mode 100644 index 0000000..ac6f984 --- /dev/null +++ b/tests/expected/183-type-alias-size-align.txt @@ -0,0 +1,7 @@ +direct s32: 4 +alias s32: 4 +chain s32: 4 +align alias: 4 +align chain: 4 +size struct-alias: 16 +align struct-alias:8 diff --git a/tests/expected/issue-0046.exit b/tests/expected/184-objc-defined-class-method-self.exit similarity index 100% rename from tests/expected/issue-0046.exit rename to tests/expected/184-objc-defined-class-method-self.exit diff --git a/tests/expected/issue-0044.txt b/tests/expected/184-objc-defined-class-method-self.txt similarity index 100% rename from tests/expected/issue-0044.txt rename to tests/expected/184-objc-defined-class-method-self.txt diff --git a/tests/expected/185-pack-fn-comptime-return.exit b/tests/expected/185-pack-fn-comptime-return.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/expected/185-pack-fn-comptime-return.exit @@ -0,0 +1 @@ +0 diff --git a/tests/expected/issue-0045.txt b/tests/expected/185-pack-fn-comptime-return.txt similarity index 100% rename from tests/expected/issue-0045.txt rename to tests/expected/185-pack-fn-comptime-return.txt diff --git a/tests/expected/186-nested-comptime-return.exit b/tests/expected/186-nested-comptime-return.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/expected/186-nested-comptime-return.exit @@ -0,0 +1 @@ +0 diff --git a/tests/expected/issue-0046.txt b/tests/expected/186-nested-comptime-return.txt similarity index 100% rename from tests/expected/issue-0046.txt rename to tests/expected/186-nested-comptime-return.txt diff --git a/tests/expected/issue-0032.txt b/tests/expected/issue-0032.txt deleted file mode 100644 index 67c6eca..0000000 --- a/tests/expected/issue-0032.txt +++ /dev/null @@ -1 +0,0 @@ -/Users/agra/projects/sx/examples/issue-0032.sx:13:1: error: duplicate impl 'Into' for source 's64' in /Users/agra/projects/sx/examples/issue-0032.sx