✓
Passing Passing: the compiler rejects this program as expected.
Code
// PINS: a name bound twice is a fault wherever the field lines live — an
// entry extended through `<:` cannot inherit around it. `Animal` binds `name`
// twice; the refusal fires whether the child merges the still-live block or
// the parent's own gate has already erased it.
import std/io
import std/proto
import std/list
std/proto(Animal) {
name: string
name: string
}
std/proto(Dog <: Animal) {
bark: i32
}
std/list:new(Dog)
| list xs |> std/io:print.ln("made")
| err e |> std/io:print.ln("ERR {{ e:s }}")
Actual compiler output
error[KORU173]: std/proto(Animal): field 'name' is bound twice — a proto entry takes each field name once
--> tests/regression/600_STDLIB/665_PROTO/665_019_proto_parent_field_bound_twice/input.k:9:0
error[KORU173]: std/proto(Dog): '<:' names unknown proto 'Animal' — extension composes declared field sets; declare the parent first
--> tests/regression/600_STDLIB/665_PROTO/665_019_proto_parent_field_bound_twice/input.k:14:0Compiler must reject:
Compilation must fail with a diagnostic.
Flows
flow ~std/proto click a branch to expand · @labels scroll to their anchor
std/proto (Animal, source: name: string
name: string)
flow ~std/proto click a branch to expand · @labels scroll to their anchor
std/proto (Dog <: Animal, source: bark: i32)
flow ~new click a branch to expand · @labels scroll to their anchor
new (Dog)
Test Configuration
MUST_ERROR