Skip to content

Commit 5e9180e

Browse files
committed
check if the field name is a defined type
1 parent 18d47ae commit 5e9180e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/AcuteML.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,13 @@ macro aml(expr)
378378
# args_param.args # empty
379379
expr.args[3], args_param, args_defaultvalue, args_type, args_var, args_name, args_function, args_literaltype, struct_name, struct_nodetype, struct_function, is_struct_mutable, args_custom_creator, args_custom_extractor, args_custom_updater, T = aml_parse(expr)
380380

381+
# check if the field name is a defined type
382+
for arg_var in args_var
383+
if isdefined(__module__, arg_var) && isa(getfield(__module__, arg_var), Type)
384+
@error "Change the field name $arg_var in struct $T to something else. The name conflicts with an already defined type name."
385+
end
386+
end
387+
381388
out = aml_create(expr, args_param, args_defaultvalue, args_type, args_var, args_name, args_function, args_literaltype, struct_name, struct_nodetype, struct_function, is_struct_mutable, args_custom_creator, args_custom_extractor, args_custom_updater, T)
382389

383390
# elseif expr isa Expr && expr.head == :tuple

0 commit comments

Comments
 (0)