Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Compiler: fix overload of union type through alias against type #8258
If you do this:
def foo(x : Int32) 1 end def foo(x : Int8 | Int32) 'a' end foo(1) # => 1
It works because
However, before this PR, when using an alias to define the union:
alias A = Int8 | Int32 def foo(x : Int32) 1 end def foo(x : A) 'a' end foo(1) # => 'a'
It didn't work well! The reason was an incorrect logic when defining which type is stricter than the other. In this case, the union type, through the alias type, ended up stricter than the other type and eventually overwrote the other method (the first method could never be called/reached).
While working on something else I noticed this was affecting this line:
and this line:
This PR fixes this situation.