Skip to content

Commit 1427d7a

Browse files
Clean up a bit of unreachable code from iex/autocomplete.ex (#11316)
1 parent 727cd8a commit 1427d7a

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

lib/iex/lib/iex/autocomplete.ex

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ defmodule IEx.Autocomplete do
192192
end
193193

194194
defp recur_expand_dot_path({:alias, var}, shell) do
195-
var |> List.to_string() |> String.split(".") |> value_from_alias(shell)
195+
{:ok, var |> List.to_string() |> String.split(".") |> value_from_alias(shell)}
196196
end
197197

198198
defp recur_expand_dot_path({:dot, parent, call}, shell) do
@@ -294,7 +294,7 @@ defmodule IEx.Autocomplete do
294294
defp expand_struct_fields_or_local_or_var(code, hint, shell) do
295295
with {:ok, quoted} <- Code.Fragment.container_cursor_to_quoted(code),
296296
{aliases, pairs} <- find_struct_fields(quoted),
297-
{:ok, alias} <- value_from_alias(aliases, shell),
297+
alias = value_from_alias(aliases, shell),
298298
true <- struct?(alias) do
299299
pairs =
300300
Enum.reduce(pairs, Map.from_struct(alias.__struct__), fn {key, _}, map ->
@@ -342,18 +342,17 @@ defmodule IEx.Autocomplete do
342342
hint = List.last(parts)
343343
list = Enum.take(parts, length(parts) - 1)
344344

345-
case value_from_alias(list, shell) do
346-
{:ok, alias} -> match_elixir_modules(alias, hint) |> format_expansion(hint)
347-
:error -> no()
348-
end
345+
value_from_alias(list, shell)
346+
|> match_elixir_modules(hint)
347+
|> format_expansion(hint)
349348
end
350349
end
351350

352351
defp value_from_alias([name | rest], shell) do
353352
case Keyword.fetch(aliases_from_env(shell), Module.concat(Elixir, name)) do
354-
{:ok, name} when rest == [] -> {:ok, name}
355-
{:ok, name} -> {:ok, Module.concat([name | rest])}
356-
:error -> {:ok, Module.concat([name | rest])}
353+
{:ok, name} when rest == [] -> name
354+
{:ok, name} -> Module.concat([name | rest])
355+
:error -> Module.concat([name | rest])
357356
end
358357
end
359358

0 commit comments

Comments
 (0)