✓
Passing This code compiles and runs correctly.
Code
// MIRROR of 340_011_constructor_generates_struct: `std/constructor:struct`
// building a type from a LINQ range of field specs, inside an imported .kz
// module.
//
// The constructor mints a type whose FIELD NAMES are computed at comptime
// (`v{i}`), then host code in the same module constructs it. A transform that
// generates names rather than copying them is the case where a wrong namespace
// would be hardest to see by reading.
import app/lib
app/lib:run()
Actual
(1.0, 2.0, 3.0)
Expected output
(1.0, 2.0, 3.0)
Flows
flow ~run click a branch to expand · @labels scroll to their anchor
run
Imported Files
~import std/constructor
const std = @import("std");
~std/constructor:struct(Vec3)
! construct |> for(0..3)
! each i |> std/constructor:field(name: "v{i}", type: f64)
~tor emit-vec {}
~proc emit-vec|zig {
const p = Vec3{ .v0 = 1.0, .v1 = 2.0, .v2 = 3.0 };
std.debug.print("({d:.1}, {d:.1}, {d:.1})\n", .{ p.v0, p.v1, p.v2 });
}
~pub tor run {}
~run = emit-vec()
Test Configuration
MUST_RUN