Gradualizer icon indicating copy to clipboard operation
Gradualizer copied to clipboard

rebar3 case clause error

Open mpope9 opened this issue 2 years ago • 2 comments

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.

mpope9 avatar Dec 16 '22 17:12 mpope9

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.

erszcz avatar Dec 16 '22 18:12 erszcz

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

mpope9 avatar Dec 16 '22 18:12 mpope9