josefs / Gradualizer

A Gradual type system for Erlang
MIT License
609 stars 35 forks source link

Wrong type in receive...after Timeout #551

Open arcusfelis opened 11 months ago

arcusfelis commented 11 months ago

Hi,

Code:

-spec wait_response(non_neg_integer() | infinity) -> _.
wait_response(Timeout) ->
    receive
       some_message ->
            ok
    after Timeout -> % Line 80
        erlang:demonitor(Mon, [flush]),
        error(timeout)
    end.

Fails with:

    The variable on line 80 at column 11 is expected to have type integer() but it has type non_neg_integer() | infinity

But Timeout = infinity is a pretty common way to disable timeouts (or allow the caller to wait forever).

Also the same issue if I use a built-in type timeout() in the spec.