✓
Passing This code compiles and runs correctly.
Code
// Test 390_101: chained self|mlir ops COMPOSE — the buffer/memref ABI pin.
//
// Two chained self|mlir ops must behave like their Zig-loop siblings in
// 390_060: init 1,2,3 through `*=2` then `+=1` yields 3,5,7. This holds
// because the generated MLIR takes the host buffer as a memref argument
// (bare-ptr call convention: convert-func-to-llvm{use-bare-ptr-memref-call-conv=1}
// → C `void f(double*)`) and mutates it IN PLACE — each op sees its
// predecessor's writes.
//
// The pin guards against the internalize-init failure shape: a kernel that
// bakes the init values into its own body computes every op from t0, so the
// chain silently prints 2,3,4 — a wrong answer, not an error.
~import std/kernel
~import std/io
~std/kernel:shape(Body) {
mass: f64,
}
~std/kernel:init(Body) {
{ mass: 1.0 },
{ mass: 2.0 },
{ mass: 3.0 },
}
| kernel k |> std/kernel:self|mlir { k.mass *= 2.0 } |> std/kernel:self|mlir { k.mass += 1.0 }
| computed c |> std/io:print.blk {
mass[0]={{ c[0].mass:f }} mass[1]={{ c[1].mass:f }} mass[2]={{ c[2].mass:f }}
}
Actual
mass[0]=3 mass[1]=5 mass[2]=7
Expected output
mass[0]=3 mass[1]=5 mass[2]=7
Flows
flow ~shape click a branch to expand · @labels scroll to their anchor
shape (expr: Body, source: mass: f64,)
flow ~init click a branch to expand · @labels scroll to their anchor
init (expr: Body, source: { mass: 1.0 },
{ mass: 2.0 },
{ mass: 3.0 },)
Test Configuration
MUST_RUN