Skip to content

Commit 9a9816e

Browse files
committedJul 1, 2024
refactor: put definition asts into a new lexical scope
1 parent 52fb2f6 commit 9a9816e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed
 

‎lib/typed_structor.ex

+9-9
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ defmodule TypedStructor do
6969
end
7070
end
7171

72-
definition =
72+
ast =
7373
quote do
7474
{module, options} = Keyword.pop(unquote(options), :module, __MODULE__)
7575

@@ -87,7 +87,12 @@ defmodule TypedStructor do
8787
unquote(register_plugins)
8888

8989
unquote(block)
90+
after
91+
:ok
92+
end
9093

94+
# create a lexical scope
95+
try do
9196
fields = Enum.reverse(@__ts_struct_fields_acc__)
9297
parameters = Enum.reverse(@__ts_struct_parameters_acc__)
9398

@@ -106,18 +111,13 @@ defmodule TypedStructor do
106111

107112
@__ts_definition__ definition
108113
@__ts_current_module__ {module, definition.options}
109-
110-
TypedStructor.__struct_ast__()
111-
TypedStructor.__type_ast__()
112-
TypedStructor.__reflection_ast__()
113114
after
114115
:ok
115116
end
116-
end
117117

118-
ast =
119-
quote do
120-
unquote(definition)
118+
TypedStructor.__struct_ast__()
119+
TypedStructor.__type_ast__()
120+
TypedStructor.__reflection_ast__()
121121

122122
# create a lexical scope
123123
try do

0 commit comments

Comments
 (0)