Skip to content

Commit 80d8afb

Browse files
authored
Merge pull request #42 from TuringLang/outer_function
Avoid method redefinition
2 parents a0db460 + 763f4ff commit 80d8afb

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/compiler.jl

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,8 @@ function build_output(model_info)
588588
end
589589
end)
590590
end
591-
return esc(quote
592-
# Allows passing arguments as kwargs
593-
$outer_function(;$(args...)) = $outer_function($(arg_syms...))
591+
592+
ex = quote
594593
function $outer_function($(args...))
595594
function $inner_function(
596595
$vi::DynamicPPL.VarInfo,
@@ -605,7 +604,17 @@ function build_output(model_info)
605604
return DynamicPPL.Model($inner_function, $args_nt, $model_gen_constructor)
606605
end
607606
$model_gen = $model_gen_constructor
608-
end)
607+
end
608+
609+
if !isempty(args)
610+
ex = quote
611+
$ex
612+
# Allows passing arguments as kwargs
613+
$outer_function(;$(args...)) = $outer_function($(arg_syms...))
614+
end
615+
end
616+
617+
return esc(ex)
609618
end
610619

611620
# A hack for NamedTuple type specialization

0 commit comments

Comments
 (0)