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
A union argument is rejected by an overloaded function that covers every member #647
A value of a union type cannot be passed to an overloaded function, even when there is an overload for every member of the union.
Repro
let describe(n: Integer) -> String = "integer ${n}"
let describe(s: String) -> String = "string ${s}"
let label(id: Integer | String) -> String = describe(id)
main do
IO.printLine(label(3))
end
Actual:
error: `describe` expects argument 1 to be Integer, but got Integer | String
describe : Integer -> String
describe : String -> String
Expected: accepted, dispatching on the value at run time, with the result typed as the join of the overloads' results (String here).
Notes
Each overload is tried against the whole union, and a union only flows to a parameter when every member fits it. Overload resolution has no step that covers the union member by member.
Reproduced on kex 0.4.0-rc.3 (266b7a60) with the type checker on.
Activity