Skip to content

Commit

Permalink
fix endless loop when expanding use
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed May 7, 2024
1 parent a9ca754 commit 8ec03be
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/elixir_sense/core/state.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,7 @@ defmodule ElixirSense.Core.State do
{ast, state, env}
end

def expand({:use, meta, _} = ast, state, env) do
def expand({:use, meta, [_ | _]} = ast, state, env) do
alias ElixirSense.Core.MacroExpander
line = Keyword.fetch!(meta, :line)

Expand Down
14 changes: 14 additions & 0 deletions test/elixir_sense/core/metadata_builder_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7450,6 +7450,20 @@ defmodule ElixirSense.Core.MetadataBuilderTest do
end
end

test "no endless loop on use variable" do
state =
"""
defmodule Some do
use
@spec my(number()) :: number()
def my(abc) do
abc + 1
end
end
"""
|> string_to_state
end

defp string_to_state(string) do
string
|> Code.string_to_quoted(columns: true, token_metadata: true)
Expand Down

0 comments on commit 8ec03be

Please sign in to comment.