-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Summary
In short, if we have a variable used within a function, say:
some variable x is declared and used a bunch
f(x)
We can use type inference to get the type of x even if we don't assign it a type above.
However, if we already know the type of x, then at most the check stage should check that it is a valid argument to the function.
If we instead match it directly, we can get weird situations if the function signature specifies the argument is a union.
Then the unification stage will also state that x is this union, which can lead to erroneous output:
Example
def f(x: {Int, Str}) -> Int => 10
def x := 10
f(x)
Will give the following:
function definition here
x: Union[int, str] = 10
f(x)
While we expect:
x: int = 10
f(x)
Metadata
Metadata
Assignees
Labels
No labels