You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Trait implementations are not checked against the trait's signatures #642
A make T, implement: Trait block is checked only for the names of the required functions and their foul markers. The types are not compared with the trait's signatures.
Repro
trait Shape do
area :> Float
end
record Square do
side : Float
end
make Square, implement: Shape do
let area = "not a number"
end
let total(s: Shape) -> Float = s.area + 1.0
main do
IO.printLine("${total(Square { side: 2.0 })}")
end
Actual: accepted; fails at run time with Cannot add String and Float.
Expected: an error on the make block saying area must return Float.
Cause
TypeChecker::checkTraitImplementation (src/semantic/typechecker.cxx:4509-4573) collects name -> isFoul for the block and compares only those. It should also compare arity, parameter types and result type against the trait's signature with This replaced by the make target.
Reproduced on kex 0.4.0-rc.3 (266b7a60) with the type checker on.
Activity