Surface rename of the signed integer family: s1..s64 become i1..i64
(u1..u64, usize, isize unchanged). 'string' keeps the s-prefix arm in
name classification; width parsing moves to the i-prefix arm next to
isize.
Internal TypeId tags follow the surface (.s8/.s16/.s32/.s64 ->
.i8/.i16/.i32/.i64), as do mono-key mangle fragments (ptr_i64,
tu_i64_bool) and all display/diagnostic formatting (i{d}).
Migrated in the same sweep: stdlib + examples + issue repros + FFI C
companions (shared symbol names like ffi_id_i64), expected
stdout/stderr/ir snapshots, specs.md, readme.md, CLAUDE.md/AGENTS.md,
implementation_plan.md, docs/, issue writeups. Vendored stb_image and
historical flow state left untouched.
zig build test: 426/426; examples suite: 595/595.
40 lines
1.5 KiB
Plaintext
40 lines
1.5 KiB
Plaintext
// Variadic heterogeneous type packs — step 3: `$args[$i]` in
|
|
// type positions.
|
|
//
|
|
// `$args[$i]` resolves to the i-th element type of the active
|
|
// pack binding wherever a type expression is expected:
|
|
// - return type: `-> $args[0]`
|
|
// - local var annotation: `x : $args[1] = ...`
|
|
// - (later: param types, fn-pointer types, struct field types)
|
|
//
|
|
// Today's parser hits "expected '{'" at the `$args[0]` token in
|
|
// the return type position because the `$<ident>` arm only
|
|
// accepts plain generic names; `[<int>]` after the name isn't
|
|
// recognised. This file pins that rejection. Next commit teaches
|
|
// the parser to accept `$<pack>[<int>]` and adds a new
|
|
// `PackIndexTypeExpr` AST node; `resolveTypeWithBindings`
|
|
// consults the active `pack_arg_types` map.
|
|
//
|
|
// The body intentionally exercises TWO positions per mono — the
|
|
// return type AND a local annotation — so the parser change has
|
|
// to cover more than just the trailing return arrow.
|
|
|
|
#import "modules/std.sx";
|
|
|
|
swap_take :: (..$args) -> $args[0] {
|
|
second : $args[1] = args[1];
|
|
// `second` is bound and typed — confirms the local-annotation
|
|
// path also resolves. The body returns args[0] (statically
|
|
// typed as $args[0]).
|
|
return args[0];
|
|
}
|
|
|
|
main :: () -> i32 {
|
|
// Heterogeneous call shapes — each picks a different concrete
|
|
// pair, gets its own mono.
|
|
a : i64 = swap_take(42, "ignored"); // $args[0] = i64, $args[1] = string
|
|
b : string = swap_take("first", 99); // $args[0] = string, $args[1] = i64
|
|
print("{} {}\n", a, b);
|
|
return 0;
|
|
}
|