Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/elixir/src/elixir_map.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ expand_struct(Meta, Left, Right, #{context := Context} = E) ->
true when is_atom(ELeft) ->
%% We always record structs when they are expanded
%% as they expect the reference at compile time.
elixir_lexical:record_remote(ELeft, nil, ?m(E, lexical_tracker));
elixir_lexical:record_remote(ELeft, '__struct__', 1, nil, ?line(Meta), ?m(E, lexical_tracker));
true ->
ok;
false when Context == match ->
Expand Down
21 changes: 13 additions & 8 deletions lib/elixir/test/elixir/kernel/lexical_tracker_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ defmodule Kernel.LexicalTrackerTest do
&R.func/0
&Remote.func/0
&Integer.is_even/1
%Macro.Env{}
end

&extract/2
Expand All @@ -171,6 +172,8 @@ defmodule Kernel.LexicalTrackerTest do

&is_record/1; def b(a), do: is_record(a)

%Macro.Env{}

Kernel.LexicalTracker.remote_dispatches(__ENV__.module)
end |> elem(3)
""")
Expand All @@ -181,14 +184,16 @@ defmodule Kernel.LexicalTrackerTest do
assert {9, Integer, :is_even, 1} in compile_remote_calls
assert {15, Record, :is_record, 1} in compile_remote_calls
assert {18, Integer, :is_even, 1} in compile_remote_calls
assert {21, Record, :extract, 2} in compile_remote_calls
assert {22, Record, :is_record, 1} in compile_remote_calls
assert {23, Remote, :func, 0} in compile_remote_calls
assert {19, Macro.Env, :__struct__, 1} in compile_remote_calls
assert {22, Record, :extract, 2} in compile_remote_calls
assert {23, Record, :is_record, 1} in compile_remote_calls
assert {24, Remote, :func, 0} in compile_remote_calls
assert {25, Integer, :is_even, 1} in compile_remote_calls
assert {27, Kernel, :def, 2} in compile_remote_calls
assert {27, Record, :is_record, 1} in compile_remote_calls
assert {29, Kernel.LexicalTracker, :remote_dispatches, 1} in compile_remote_calls
assert {25, Remote, :func, 0} in compile_remote_calls
assert {26, Integer, :is_even, 1} in compile_remote_calls
assert {28, Kernel, :def, 2} in compile_remote_calls
assert {28, Record, :is_record, 1} in compile_remote_calls
assert {30, Macro.Env, :__struct__, 1} in compile_remote_calls
assert {32, Kernel.LexicalTracker, :remote_dispatches, 1} in compile_remote_calls

runtime_remote_calls = unroll_dispatches(runtime_remote_calls)
assert {7, Record, :extract, 2} in runtime_remote_calls
Expand All @@ -200,7 +205,7 @@ defmodule Kernel.LexicalTrackerTest do
assert {16, Remote, :func, 0} in runtime_remote_calls
assert {17, Remote, :func, 0} in runtime_remote_calls
assert {18, :erlang, :==, 2} in runtime_remote_calls
assert {27, :erlang, :is_tuple, 1} in runtime_remote_calls
assert {28, :erlang, :is_tuple, 1} in runtime_remote_calls
end

defp unroll_dispatches(dispatches) do
Expand Down