File tree Expand file tree Collapse file tree 4 files changed +11
-1
lines changed Expand file tree Collapse file tree 4 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 4
4
5
5
* bug fix
6
6
* [ Dict] ` Enum.to_list ` and ` Dict.to_list ` now return the same results for dicts
7
+ * [ Record] Fix a bug where nested records cannot be defined
7
8
* [ Mix] Fix a bug where ` mix deps.get ` was not retrieving nested dependencies
8
9
9
10
* deprecations
Original file line number Diff line number Diff line change @@ -424,6 +424,9 @@ defmodule Kernel.SpecialForms do
424
424
module name. This means that the variable is associated to the
425
425
ContextSample module and only code generated by this module
426
426
will be able to access that particular `world` variable.
427
+ While this means macros from the same module could have
428
+ conflicting variables, it also allows different quotes from
429
+ the same module to access them.
427
430
428
431
The context can be disabled or changed by explicitly setting
429
432
the context option. All hygiene mechanisms are based on such
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ defmodule Record do
26
26
block = Keyword . get ( opts , :do , nil )
27
27
28
28
quote do
29
- values = unquote ( values )
29
+ unquoted_values = unquote ( values )
30
30
31
31
defmodule unquote ( name ) do
32
32
@ moduledoc false
@@ -35,6 +35,10 @@ defmodule Record do
35
35
@ record_fields [ ]
36
36
@ record_types [ ]
37
37
38
+ # Reassign values to inner scope to
39
+ # avoid conflicts in nested records
40
+ values = unquoted_values
41
+
38
42
Record . deffunctions ( values , __ENV__ )
39
43
value = unquote ( block )
40
44
Record . deftypes ( values , @ record_types , __ENV__ )
Original file line number Diff line number Diff line change @@ -56,6 +56,8 @@ defmodule RecordTest.Macros do
56
56
def nested_record_alias? ( Nested [ ]) do
57
57
true
58
58
end
59
+
60
+ defrecord NestedInNested , it_compiles: true
59
61
end
60
62
61
63
def new ( ) do
You can’t perform that action at this time.
0 commit comments