Skip to content

Commit

Permalink
Fix infinite loop when parsing macro in wild attribute name
Browse files Browse the repository at this point in the history
  • Loading branch information
gomoripeti committed Feb 19, 2021
1 parent df50bd4 commit be34322
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/els_lsp/src/els_parser.erl
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ attribute_name_atom(Tree) ->
atom ->
erl_syntax:atom_value(NameNode);
_ ->
Tree
NameNode
end.

-spec attribute_subtrees(atom() | tree(), [tree()]) -> [[tree()]].
Expand Down
8 changes: 8 additions & 0 deletions apps/els_lsp/test/els_parser_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
, spec_macro/1
, type_macro/1
, opaque_macro/1
, wild_attrbibute_macro/1
]).

%%==============================================================================
Expand Down Expand Up @@ -206,6 +207,13 @@ opaque_macro(_Config) ->
?assertMatch([_], parse_find_pois(Text, macro, 'M')),
ok.

-spec wild_attrbibute_macro(config()) -> ok.
wild_attrbibute_macro(_Config) ->
Text = "-?M(foo).",
?assertMatch([_], parse_find_pois(Text, macro, 'M')),
?assertMatch([_], parse_find_pois(Text, atom, foo)),
ok.

%%==============================================================================
%% Helper functions
%%==============================================================================
Expand Down

0 comments on commit be34322

Please sign in to comment.