✓
Passing Passing: the compiler rejects this program as expected.
Code
// PINS: the REFUSAL of a second `std/indexes:store` declaration naming the
// same store. One index per store is the ruling today — a second
// declaration used to be silently dropped (the discovery walk returned the
// first match and nothing else looked), which is the banned silent-drop:
// the author believes `val` is indexed and `! first` on it scans forever.
// The store's own emit site refuses at the second declaration's location.
//
// Same ruling covers a re-declaration of the same column — any second
// claim on the store is refused, not just a different-column one.
import std/store
import std/indexes
import std/io
std/store:new(players, capacity: 8) { key: i64, val: i64 }
std/indexes:store(players, key)
std/indexes:store(players, val)
std/io:print.ln("unreachable")
Actual compiler output
error[KORU161]: std/indexes:store(players, val): 'players' already carries an index on 'key' - a second index on one store is a later rung
--> tests/regression/600_STDLIB/690_STORE/690_328_index_second_decl_refuses/input.k:17:0Must fail at runtime:
Program must error when executed.
Error output must contain
already carries an indexFlows
flow ~new click a branch to expand · @labels scroll to their anchor
new (players, capacity: 8, source: key: i64, val: i64)
flow ~store click a branch to expand · @labels scroll to their anchor
store (expr: players, key, source: <implicit_source>)
flow ~store click a branch to expand · @labels scroll to their anchor
store (expr: players, val, source: <implicit_source>)
flow ~print.ln click a branch to expand · @labels scroll to their anchor
print.ln (expr: "unreachable")
Test Configuration
MUST_ERROR