Open lbueso opened 2 years ago
Thank you for submitting this bug report!
Defining multiple different specs for the same function is indeed allowed in Elixir/Erlang's own typespecs, but not currently in TypeCheck. We do want to support this in the future, but it requires some work to get the implementation right. Maybe the current limitation was surprising. Do you think we should make it more visible in the documentation maybe?
For the time being, I recommend writing down a single spec in the format
@spec! f(integer()) :: integer() | boolean()
Making it more visible in the documentation will definetely be very useful while this is not implemented.
Maybe TypeCheck could also throw a compilation warning when it finds more than one spec for a function. This will be very useful for the user, because the current behaviour doesn't allow the user to correctly invoke the function with multiple specs.
With this function definition of
f
I would expect TypeCheck to allow calling f with integers and booleans, but the current behaviour is: