Skip to content

Commit

Permalink
Add debugging for issue erlang-ls#1288 (erlang-ls#1289)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoaloi committed May 5, 2022
1 parent 95e906e commit 4449a63
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions apps/els_lsp/src/els_bound_var_in_pattern_diagnostics.erl
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,22 @@ find_vars(Uri) ->
find_vars_in_form(Form) ->
case erl_syntax:type(Form) of
function ->
AnnotatedForm = erl_syntax_lib:annotate_bindings(Form, []),
%% There are no bound variables in function heads or guards
%% so lets descend straight into the bodies
Clauses = erl_syntax:function_clauses(AnnotatedForm),
ClauseBodies = lists:map(fun erl_syntax:clause_body/1, Clauses),
fold_subtrees(ClauseBodies, []);
%% #1288: The try catch should allow us to understand the root cause
%% of the occasional crashes, which could be due to an incorrect mapping
%% between the erlfmt AST and erl_syntax AST
try
AnnotatedForm = erl_syntax_lib:annotate_bindings(Form, []),
%% There are no bound variables in function heads or guards
%% so lets descend straight into the bodies
Clauses = erl_syntax:function_clauses(AnnotatedForm),
ClauseBodies = lists:map(fun erl_syntax:clause_body/1, Clauses),
fold_subtrees(ClauseBodies, [])
catch C:E:St ->
?LOG_ERROR("Error annotating bindings "
"[form=~p] [class=~p] [error=~p] [stacktrace=~p]",
[Form, C, E, St]),
[]
end;
_ ->
[]
end.
Expand Down

0 comments on commit 4449a63

Please sign in to comment.