When looking for the type of a variable, the type-checker was traversing the scopes in the reverse order, giving priority to shallower bindings. In a nutshell, the following program was considered correct:
x: Int = 5
x: Bool = 10
x + 1
The type-checker was not checking that the type of the body of a recursive function coincided with the annotated type in the signature of the function. Meaning that the following program was considered correct:
This PR fixes two bugs:
Those cases were added as tests too.