✓
Passing This code compiles and runs correctly.
Code
// Pins the CROSS-MODULE entity discharger. An [entity] store synthesizes Enemy
// and its `take` mints <std/store:taken!>; the despawn handler lives in a
// SEPARATE module (despawner.k), names the type as `input:Enemy`, and consumes
// <std/store:!taken> (bare state is illegal outside the declaring module —
// 330_088). Discharge is LEFT IMPLICIT: auto-discharge must resolve the sole
// consumer ACROSS the module boundary and insert it. Sibling to 330_087 /
// 330_089 — here on the discharger-resolution side rather than the checker.
import std/io
import std/store
import app/despawner
[entity(enemy)]std/store:new(enemies, capacity: 64) { hp: i64 }
std/store:insert(enemies) { hp: 9 }
| row r |> std/store:take(enemies[r])
| item i |> std/io:print.ln("took hp {{ i.hp:d }}")
Supporting Files
// The despawn handler for Enemy, authored in a SEPARATE module. It consumes the
// module-qualified taken-obligation <std/store:!taken> and names the entity type
// via the cross-module type form `input:Enemy` (Enemy is synthesized in the main
// module — 220_001's module:Type syntax). Bare <!taken> would be rejected here
// per 330_088. Never called explicitly: auto-discharge is the sole caller.
import std/io
pub tor discharge-enemy { enemy: input:Enemy<std/store:!taken> }
discharge-enemy = std/io:print.ln("despawned an enemy")
Actual
took hp 9
despawned an enemy
Must contain:
despawned an enemyFlows
flow ~new click a branch to expand · @labels scroll to their anchor
new (enemies, capacity: 64, source: hp: i64)
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (enemies, source: hp: 9)
Test Configuration
MUST_RUN
koru.json:
{
"paths": {
"std": "../../../../../koru_std",
"app": "."
}
}