✓
Passing Passing: the compiler rejects this program as expected.
Code
// TEST: KORU182 on a kernel `| computed` receiver — the nbody trap shape
//
// `c[i].x-c[j]` unspaced resolves `x-c` as one member NAME — under the
// uniform `-`-is-an-identifier ruling it was never subtraction. The flow
// checker resolves the `| computed` binding to the kernel's `shape(T)`
// field set ({x, mass} here) and fires KORU182: `x-c` is no field, `x`
// is, `c` resolves. Complement of 390_129, which pins the same program
// written correctly with spaced subtraction.
//
// Note the nbody showcase's own carrier stays behind a named wall:
// `captured { ... }` args carry captured source (transform data), which
// this pass does not open — same contract as 220_055's transform-condition
// gap. The diagnostic covers every SCANNED carrier; captured-source text
// is a separate decision.
import std/kernel
import std/io
tor sink { v: f64 } -> i64
sink -> 0
std/kernel:shape(Body) {
x: f64,
mass: f64,
}
std/kernel:init(Body) {
{ x: 0.0, mass: 1.0 },
{ x: 1.0, mass: 2.0 },
}
| kernel k |> std/kernel:self { k.x += 1.0 }
| computed c |> sink(v: c[0].x-c[1].x): r |> std/io:print.ln(v: r)
Actual compiler output
error[KORU182]: 'c[0].x-c' reads as the field name 'x-c', not subtraction — `-` joins identifiers (kebab), and 'c[0]' has no field 'x-c'
--> tests/regression/300_ADVANCED_FEATURES/390_KERNEL/390_130_computed_member_kebab_koru182/input.k:32:1
|
32 | | computed c |> sink(v: c[0].x-c[1].x): r |> std/io:print.ln(v: r)
| ^
hint: for subtraction write the segments spaced: 'x - c'Frontend must reject with:
CONTAINS error[KORU182
CONTAINS reads as the field name 'x-c', not subtraction
CONTAINS 'c[0]' has no field 'x-c'Flows
flow ~shape click a branch to expand · @labels scroll to their anchor
shape (expr: Body, source: x: f64,
mass: f64,)
flow ~init click a branch to expand · @labels scroll to their anchor
init (expr: Body, source: { x: 0.0, mass: 1.0 },
{ x: 1.0, mass: 2.0 },)
Test Configuration
MUST_ERROR