-
Notifications
You must be signed in to change notification settings - Fork 35
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
Crash with Uncaught error: function_clause #530
Comments
Thanks, @ilya-klyuchnikov! Can you share a (possibly minimised) snippet on which this happens? Generally, a denormalised type like Gradualizer/src/typechecker.erl Lines 3954 to 3957 in 01a1931
But, apparently, something's falling through the cracks 🤔 |
For more context, simple examples like these don't trigger this:
And while a trivial patch like this should fix the problem, I'd be hesitant to merge it without understanding what expression leads to the crash in the first place. |
I am trying to run gradualizer on a fairly large project. How do I find out what it analyzes when it fails? |
Please add {gradualizer_opts, [
verbose
]}. to
which should make it possible to pinpoint where the problem is. It might help to run Gradualizer app by app in a big umbrella repo, to limit the scope. This use case is certainly not polished for large code bases yet, but with the available resources we have to pick our battles. |
A minimized repro: -module(gradualizer_repro).
-compile([export_all, nowarn_export_all]).
-spec to_i(term()) -> integer().
to_i(_) -> error(example).
-spec to_b(term()) -> boolean().
to_b(_) -> error(example).
-spec to_x
(term(), to_i | i, Default) -> integer() | Default;
(term(), to_b | b, Default) -> boolean() | Default.
to_x(Value, _, Default) when Value =:= Default ->
Default;
to_x(Value, to_i, _) -> to_i(Value);
to_x(Value, i, _) -> to_i(Value);
to_x(Value, to_b, _) -> to_b(Value);
to_x(Value, b, _) -> to_b(Value).
|
Thanks for the example, @ilya-klyuchnikov! It's most likely the case that spurious types reach |
Trying to run it on our code base:
Looking into
gradualizer_lib:pick_value
- it doesn't expectterm()
type.The text was updated successfully, but these errors were encountered: