Files
sx/examples/182-compound-type-in-expression.sx
agra 280c12c630 issues: promote 6 fixed bug repros to focused regression tests
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.
2026-05-28 12:14:52 +03:00

35 lines
1.2 KiB
Plaintext

// 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";
// Unambiguous type-form const-decl aliases.
Ptr :: *u8;
Maybe :: ?u8;
Arr :: [3]u8;
Cb :: (s32) -> s32;
main :: () -> s32 {
// Direct: parser fix for *T, ?T + existing [N]T path.
print("size_of(*u8) = {}\n", size_of(*u8));
print("align_of(*u8) = {}\n", align_of(*u8));
print("size_of(?u8) = {}\n", size_of(?u8));
print("size_of([3]u8) = {}\n", size_of([3]u8));
// Function-type literal in expression position.
print("size_of((s32)->s32) = {}\n", size_of((s32) -> s32));
// Tuple literal reinterpreted as tuple type at the type-demanding site.
print("size_of((s32, s32)) = {}\n", size_of((s32, s32)));
// Aliases.
print("size_of(Ptr) = {}\n", size_of(Ptr));
print("size_of(Maybe) = {}\n", size_of(Maybe));
print("size_of(Arr) = {}\n", size_of(Arr));
print("size_of(Cb) = {}\n", size_of(Cb));
0;
}