Yes, it seems to be "expected." Looking at the source code here, He checks the meaning
-define(SET_LIMIT, 13).
in the test
t_from_range(X, Y) when is_integer(X), is_integer(Y) -> case ((Y - X) < ?SET_LIMIT) of true -> t_integers(lists:seq(X, Y)); false -> case X >= 0 of false -> if Y < 0 -> ?integer_neg; true -> t_integer() end; true -> if Y =< ?MAX_BYTE, X >= 1 -> ?int_range(1, ?MAX_BYTE); Y =< ?MAX_BYTE -> t_byte(); Y =< ?MAX_CHAR, X >= 1 -> ?int_range(1, ?MAX_CHAR); Y =< ?MAX_CHAR -> t_char(); X >= 1 -> ?integer_pos; X >= 0 -> ?integer_non_neg end end end;
IMHO it seems dangerous and does not give any real guarantees. This should be clearly documented. There is a link to find out about this Erlang site .
The range of integers. For example, if you want to represent the number of months in a year, a range of 1.12 can be defined. Please note that Dialyzer reserves the right to expand this range to a larger one.
But nothing official on the Google homepage using the dialyzer integer ranges keywords
Edit ... a little closer, you can see that if you try:
-module(test). -export([h/0]). -spec h() -> RESULT when RESULT :: 1..13 . h () -> 100 .
The dialyzer will catch a mistake! (Typer will not) ...
source share