Binary comprehensions don't match subtyping
-spec iodata_binary() -> iodata().
iodata_binary() ->
<<<<"A">> || _ <- lists:seq(1, 10)>>.
This is a testcase extracted from some actual code of mine where I would expect Gradualizer not to give me the error:
The binary comprehension on line 7 at column 5 is expected to have type iodata() which has no binary subtypes
Which is pretty much senseless, binary() is a subtype of iodata(), for example here: https://github.com/josefs/Gradualizer/blob/beac8edf9bfb1d5fe77d4068126c55249a6a6ab7/src/typechecker.erl#L663-L664
Trying to have a look at where Gradualizer makes this mistake, I arrived at this line: https://github.com/josefs/Gradualizer/blob/beac8edf9bfb1d5fe77d4068126c55249a6a6ab7/src/typechecker.erl#L2771-L2772
This function is called with parameters ResTy: {type,{5,26},union,[{type,{5,26},iolist,[]},{type,{5,26},binary,[]}]}, which doesn't match any of the case statements.
I'm trying to have a look if I can fix it and make a PR myself, (from this branch https://github.com/NelsonVides/Gradualizer/tree/binary_comprehension) (maybe using fun subtype/3 or so?), so if you have any suggestions for me I'd very much appreciate it 🙂