test(ir): lock call lowering with .ir snapshots + classification tests (A3.2 convergence step 1)
Test-first scaffolding before the CallPlan convergence — no call-code change. Locks current call behavior so the later lowerCall rewrite is guarded. - .ir snapshots for representative call forms: 0031 (direct local-fn + dot-shorthand enum ctor), 0032 (UFCS/struct method), 0301 (closure/ fn-pointer slot), 0400 (protocol dispatch + static-through-impl). - New focused example 0044-basic-default-arg-expansion + .ir snapshot, pinning call-site default expansion (scale(5)->scale(ctx,5,2), label(1)->label(ctx,1,"v","!")). Foreign-class instance+static is already pinned by the existing FFI .ir set. - Broaden calls.test.zig (scope-free classification): remaining reflection builtins, sqrt->f64, cast->resolved type arg, enum_literal->target_type. 1033 (#caller_location) was rejected as a snapshot: it embeds the absolute source path as a length-typed string that normalize_ir can't reconcile; default-arg coverage uses the path-free 0044 instead. Gate green: zig build, zig build test, tests/run_examples.sh -> 357/0.
This commit is contained in:
23
examples/0044-basic-default-arg-expansion.sx
Normal file
23
examples/0044-basic-default-arg-expansion.sx
Normal file
@@ -0,0 +1,23 @@
|
||||
// Call-site default-argument expansion (`appendDefaultArgs` / `expandCallDefaults`
|
||||
// in lowerCall). A call that omits a trailing parameter with a default value
|
||||
// has the default expression spliced in at the call site; an explicit argument
|
||||
// overrides it. Two trailing defaults cover the "fill all remaining" path.
|
||||
// Path-free IR (literal defaults) so the `.ir` snapshot is location-stable.
|
||||
|
||||
#import "modules/std.sx";
|
||||
|
||||
scale :: (n: s32, factor: s32 = 2) -> s32 { n * factor }
|
||||
|
||||
label :: (n: s32, prefix: string = "v", suffix: string = "!") -> s32 {
|
||||
print("{}{}{}\n", prefix, n, suffix);
|
||||
n
|
||||
}
|
||||
|
||||
main :: () {
|
||||
print("default: {}\n", scale(5));
|
||||
print("explicit: {}\n", scale(5, 3));
|
||||
|
||||
_ = label(1); // both defaults filled
|
||||
_ = label(2, "x"); // suffix default filled
|
||||
_ = label(3, "y", "?"); // no defaults
|
||||
}
|
||||
4175
examples/expected/0031-basic-local-fn-return.ir
Normal file
4175
examples/expected/0031-basic-local-fn-return.ir
Normal file
File diff suppressed because it is too large
Load Diff
3797
examples/expected/0032-basic-ufcs-return-type.ir
Normal file
3797
examples/expected/0032-basic-ufcs-return-type.ir
Normal file
File diff suppressed because it is too large
Load Diff
1
examples/expected/0044-basic-default-arg-expansion.exit
Normal file
1
examples/expected/0044-basic-default-arg-expansion.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
3399
examples/expected/0044-basic-default-arg-expansion.ir
Normal file
3399
examples/expected/0044-basic-default-arg-expansion.ir
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
||||
default: 10
|
||||
explicit: 15
|
||||
v1!
|
||||
x2!
|
||||
y3?
|
||||
3314
examples/expected/0301-closures-fn-pointers.ir
Normal file
3314
examples/expected/0301-closures-fn-pointers.ir
Normal file
File diff suppressed because it is too large
Load Diff
3415
examples/expected/0400-protocols-impl-for-builtin.ir
Normal file
3415
examples/expected/0400-protocols-impl-for-builtin.ir
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user