josefs / Gradualizer

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

rebar3 case clause error #497

Open mpope9 opened 1 year ago

mpope9 commented 1 year ago

Have an issue running gradualizer with rebar3. Here is the stacktrace:

Error: {case_clause,error}
[{typechecker,get_bounded_fun_type_list,4,
              [{file,"/Users/my_user/my_project/_build/default/plugins/gradualizer/src/typechecker.erl"},
               {line,3348}]},
 {typechecker,type_check_fun,3,
              [{file,"/Users/my_user/my_project/_build/default/plugins/gradualizer/src/typechecker.erl"},
               {line,3182}]},
 {typechecker,do_type_check_expr_in,3,
              [{file,"/Users/my_user/my_project/_build/default/plugins/gradualizer/src/typechecker.erl"},
               {line,2548}]},
 {typechecker,type_check_expr_in,3,
              [{file,"/Users/my_user/my_project/_build/default/plugins/gradualizer/src/typechecker.erl"},
               {line,2298}]},
 {typechecker,'-type_check_call_ty/4-lc$^0/1-0-',2,
              [{file,"/Users/my_user/my_project/_build/default/plugins/gradualizer/src/typechecker.erl"},
               {line,2125}]},
 {typechecker,type_check_call_ty,4,
              [{file,"/Users/my_user/my_project/_build/default/plugins/gradualizer/src/typechecker.erl"},
               {line,2126}]},
 {typechecker,do_type_check_expr,2,
              [{file,"/Users/my_user/my_project/_build/default/plugins/gradualizer/src/typechecker.erl"},
               {line,1664}]},
 {typechecker,type_check_expr,2,
              [{file,"/Users/my_user/my_project/_build/default/plugins/gradualizer/src/typechecker.erl"},
               {line,1541}]}]

I sadly cannot seem to repro this using gradualizer stand alone. The only 'issue' I can see is that when the file directly through graduailzer there is one error that stands out:

Call to undefined function

The function that is being called is exported and used frequently elsewhere. Removing that function doesn't fix the crash. The files before and after the one that causes the failure run fine directly in gradualizer as well. Getting an actual repo outside of the project is proving tricky.

erszcz commented 1 year ago

Thanks for raising this, @mpope9!

It's a bit hard to tell what's going on without reference to the code - I understand the code in question is private, isn't it? It would help immensely if you could reproduce the issue outside the private repo, e.g. in a minimal project with a rebar.config and Gradualizer as a dependency.

In general, the problem seems related to access to the spec of the function in question. It might be the case that the rebar plugin doesn't set up the paths to .beam files properly. On the other hand, the type checker seems to look for a spec of a local function (typechecker.erl:3182), which should always be accessible (either a real spec or a fun(... -> any()) stub).

I'll try reproducing this, we'll see how it goes.

mpope9 commented 1 year ago

@erszcz Thanks! I'll see what I can try and whip up myself.