-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix crashes on ExDoc #79
Conversation
With #79 and josefs/Gradualizer#415 the current error is:
|
With this Gradualizer diff:
We get this log (truncated):
Which leads to location 327 - the line with the pinning operators below: defp find_function_line(module_data, {name, arity}) do
Enum.find_value(module_data.private.abst_code, fn
{:function, anno, ^name, ^arity, _} -> anno_line(anno)
_ -> nil
end)
end It seems the pinning operator compiles down to guards which are a problem for both Gradient (https://github.com/esl/gradient/blob/main/lib/gradient/ast_specifier.ex#L543-L553) and Gradualizer (https://github.com/josefs/Gradualizer/blob/master/src/typechecker.erl#L3371 - |
It seems to me we miss logic to handle non-unary guard lists in https://github.com/esl/gradient/blob/main/lib/gradient/ast_specifier.ex#L543-L553. Let's consider the following example: 3> merl:quote("fun (A, B) when A =:= 1; B =:= 2, B =/= 3 -> ok end").
{'fun',1,
{clauses,[{clause,1,
[{var,1,'A'},{var,1,'B'}],
[[{op,1,'=:=',{var,1,'A'},{integer,1,1}}],
[{op,1,'=:=',{var,1,'B'},{integer,1,2}},
{op,1,'=/=',{var,1,'B'},{integer,1,3}}]],
[{atom,1,ok}]}]}} The alternative has two conjunctions ( |
This patch fixes the crash, but it doesn't pass the guards through
|
Returning an improper list, as IO.ANSI.format() does, leads to gradualizer_fmt crashing on the ++ operator. See #78 for the original report.
b499b88
to
2fb4b42
Compare
This doesn't crash on ExDoc anymore. It reports some errors, though not a lot. I've not revised them yet, so some reported errors might be false positives, but at the very least we do not crash anymore. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good :)
This partially addresses #78. Fixing the initial
IO.ANSI.format()
issue uncovers more crashes which also have to be taken care of.