✓
Passing This code compiles and runs correctly.
Code
// A view sweep whose body WRITES to another store, reading the shared leaf in
// the write expression. 690_287's sweep body is a print.ln call: the read path
// threads the leaf into the handler input and each member loop binds it. A
// stored-write body took the .live lowering instead — the RHS re-read the leaf
// from `__koru_store_Entities.str[...]`, a store that does not exist (a view
// has no backing array), and the backend refused with `use of undeclared
// identifier '__koru_store_Entities'`. The write side must thread the leaf
// exactly like the read side: the projected value, bound per member loop.
//
// The guarded twin (`when e is Player` + stored body) is pinned here too —
// the kind guard folds to a per-member constant and the write body must still
// read through the projection (the shape the 006 benchmark's view_player arm
// measures).
import std/io
import std/proto
import std/store
std/proto:i64(Strength)
std/proto:i64(Mana)
std/proto:i64(Armor)
std/proto(Player) {
str: Strength
mana: Mana
}
std/proto(Enemy) {
str: Strength
armor: Armor
}
std/store:new(Player, capacity: 8) { Player }
std/store:new(Enemy, capacity: 8) { Enemy }
std/store:view(Entities) {
Player
Enemy
}
std/store:new(acc) { sink: 0[i64], player_sink: 0[i64] }
std/store:insert(Player) { str: 18, mana: 12 }
std/store:insert(Enemy) { str: 10, armor: 5 }
std/store:query(Entities)
! query e |> std/store:stored { acc.sink: acc.sink + e.str }
std/store:query(Entities)
! query e when e is Player |> std/store:stored { acc.player_sink: acc.player_sink + e.str }
std/io:print.ln("sink {{ acc.sink:d }}")
std/io:print.ln("player_sink {{ acc.player_sink:d }}")
Actual
sink 28
player_sink 18
Expected output
sink 28
player_sink 18
Flows
flow ~i64 click a branch to expand · @labels scroll to their anchor
i64 (expr: Strength)
flow ~i64 click a branch to expand · @labels scroll to their anchor
i64 (expr: Mana)
flow ~i64 click a branch to expand · @labels scroll to their anchor
i64 (expr: Armor)
flow ~std/proto click a branch to expand · @labels scroll to their anchor
std/proto (Player, source: str: Strength
mana: Mana)
flow ~std/proto click a branch to expand · @labels scroll to their anchor
std/proto (Enemy, source: str: Strength
armor: Armor)
flow ~new click a branch to expand · @labels scroll to their anchor
new (Player, capacity: 8, source: Player)
flow ~new click a branch to expand · @labels scroll to their anchor
new (Enemy, capacity: 8, source: Enemy)
flow ~view click a branch to expand · @labels scroll to their anchor
view (Entities, source: Player
Enemy)
flow ~new click a branch to expand · @labels scroll to their anchor
new (acc, source: sink: 0[i64], player_sink: 0[i64])
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (Player, source: str: 18, mana: 12)
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (Enemy, source: str: 10, armor: 5)
flow ~query click a branch to expand · @labels scroll to their anchor
query (Entities)
flow ~query click a branch to expand · @labels scroll to their anchor
query (Entities)
flow ~print.ln click a branch to expand · @labels scroll to their anchor
print.ln (expr: "sink {{ acc.sink:d }}")
flow ~print.ln click a branch to expand · @labels scroll to their anchor
print.ln (expr: "player_sink {{ acc.player_sink:d }}")
Test Configuration
MUST_RUN