Skip to content

Commit 2ce9d25

Browse files
committed
Do not error autocompletion with module attribute, closes #11120
1 parent b558142 commit 2ce9d25

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/iex/lib/iex/autocomplete.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ defmodule IEx.Autocomplete do
163163
{:ok, List.to_atom(var)}
164164
end
165165

166+
defp expand_dot_path({:module_attribute, _}, _shell) do
167+
:error
168+
end
169+
166170
defp expand_dot_path({:dot, parent, call}, shell) do
167171
case expand_dot_path(parent, shell) do
168172
{:ok, %{} = map} -> Map.fetch(map, List.to_atom(call))

lib/iex/test/iex/autocomplete_test.exs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ defmodule IEx.AutocompleteTest do
161161
assert expand('Xyz') == {:no, '', []}
162162
assert expand('x.Foo') == {:no, '', []}
163163
assert expand('x.Foo.get_by') == {:no, '', []}
164+
assert expand('@foo.bar') == {:no, '', []}
164165
end
165166

166167
test "Elixir root submodule completion" do
@@ -221,21 +222,21 @@ defmodule IEx.AutocompleteTest do
221222
assert expand('map.f') == {:no, '', []}
222223
end
223224

224-
test "autocompletion off a bound variable only works for modules and maps" do
225+
test "bound variables for modules and maps" do
225226
eval("num = 5; map = %{nested: %{num: 23}}")
226227
assert expand('num.print') == {:no, '', []}
227228
assert expand('map.nested.num.f') == {:no, '', []}
228229
assert expand('map.nested.num.key.f') == {:no, '', []}
229230
end
230231

231-
test "autocompletion using access syntax does is not supported" do
232+
test "access syntax is not supported" do
232233
eval("map = %{nested: %{deeply: %{num: 23}}}")
233234
assert expand('map[:nested][:deeply].n') == {:no, '', []}
234235
assert expand('map[:nested].deeply.n') == {:no, '', []}
235236
assert expand('map.nested.[:deeply].n') == {:no, '', []}
236237
end
237238

238-
test "autocompletion off of unbound variables is not supported" do
239+
test "unbound variables is not supported" do
239240
eval("num = 5")
240241
assert expand('other_var.f') == {:no, '', []}
241242
assert expand('a.b.c.d') == {:no, '', []}

0 commit comments

Comments
 (0)