✓
Passing Passing: the compiler rejects this program as expected.
Code
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:insert(Player) { str: 18, mana: 12 }
std/store:insert(Enemy) { str: 10, armor: 5 }
std/store:query(Entities)
! query e when e is Bogus |> std/io:print.ln("x {{ e.str:d }}")
Actual compiler output
error[KORU161]: std/store:query(Entities): unknown kind 'Bogus' - members are: Player, Enemy (seed order, 1-based)
--> tests/regression/600_STDLIB/690_STORE/690_288_view_guard_unknown_kind_refused/input.k:30:0Must fail at runtime with:
CONTAINS unknown kind 'Bogus'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 ~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)
Test Configuration
MUST_ERROR