Skip to content

Commit

Permalink
Handle Dicts better in interface definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
davidanthoff committed Sep 7, 2024
1 parent fe4b26d commit 2939cce
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/interface_def.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ macro dict_readable(arg)
if !(field isa LineNumberNode)
fieldname = string(field.args[1])
fieldtype = field_type(field, string(tname))
if fieldtype isa Expr && fieldtype.head == :curly && fieldtype.args[2] != :Any
if fieldtype isa Expr && fieldtype.head == :curly && length(fieldtype.args)==3 && fieldtype.args[1]==:Dict
f = :($(fieldtype)(i for i in pairs(dict[$fieldname])))
elseif fieldtype isa Expr && fieldtype.head == :curly && fieldtype.args[2] != :Any
f = :($(fieldtype.args[2]).(dict[$fieldname]))
elseif fieldtype != :Any
f = :($(fieldtype)(dict[$fieldname]))
Expand Down

0 comments on commit 2939cce

Please sign in to comment.