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
Overloaded call with an untyped argument is resolved by guess and runs the wrong overload #643
When a function with several overloads is called with an argument whose type is not known yet, the checker picks one overload and types the argument from it. The call is then resolved to that overload for every caller.
Repro
let describe(n: Integer) -> String = "integer ${n}"
let describe(s: String) -> String = "string ${s}"
let show(x) = describe(x)
main do
IO.printLine(show(1))
IO.printLine(show(2.5))
end
Actual: accepted; prints integer 1 and then string 2.5. A Float reached the String overload.
Expected: either an error at describe(x) asking for an annotation on x (several overloads, argument type unknown), or show(2.5) rejected because no overload takes a Float. It should never run the wrong overload.
Cause
After an overload is chosen, checkCall binds a still-unknown argument to the winner's parameter type (src/semantic/typechecker_expr.cxx:5914-5936; the receiver case is tracked in m_guessedReceiverTypes). With one candidate that is inference; with several it is a guess.
Reproduced on kex 0.4.0-rc.3 (266b7a60) with the type checker on.
Activity