Skip to content

Commit 0328d86

Browse files
author
José Valim
committed
Check if a module is open or not when defining a record
1 parent 05b650f commit 0328d86

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

lib/elixir/lib/kernel.ex

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,14 +3247,9 @@ defmodule Kernel do
32473247
true ->
32483248
fields =
32493249
try do
3250-
module = caller.module
3251-
3252-
# We are using the access protocol in the same
3253-
# module that defines it. It works, but we need
3254-
# to read the field values from @record_fields.
3255-
case atom do
3256-
^module -> Module.get_attribute(module, :record_fields)
3257-
_ -> atom.__record__(:fields)
3250+
case Module.open?(atom) do
3251+
true -> Module.get_attribute(atom, :record_fields)
3252+
false -> atom.__record__(:fields)
32583253
end
32593254
rescue
32603255
UndefinedFunctionError ->

0 commit comments

Comments
 (0)