Skip to content

Commit 9ee336b

Browse files
committed
formatting and added test for return-value and submodel
1 parent 73962ad commit 9ee336b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/submodel_macro.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ function submodel(prefix_expr, expr, ctx=esc(:__context__))
225225
return if args_assign === nothing
226226
ctx = prefix_submodel_context(prefix, ctx)
227227
quote
228-
$retval, $(esc(:__varinfo__)) = $(DynamicPPL._evaluate!!)($(esc(expr)), $(esc(:__varinfo__)), $(ctx))
228+
$retval, $(esc(:__varinfo__)) = $(DynamicPPL._evaluate!!)(
229+
$(esc(expr)), $(esc(:__varinfo__)), $(ctx)
230+
)
229231
$retval
230232
end
231233
else

test/compiler.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,5 +570,15 @@ end
570570

571571
@model demo() = x ~ Normal()
572572
retval, svi = DynamicPPL.evaluate!!(demo(), SimpleVarInfo(), SamplingContext())
573+
574+
# Return-value when using `@submodel`
575+
@model inner() = x ~ Normal()
576+
# Without assignment.
577+
@model outer() = @submodel inner()
578+
@test outer()() isa Real
579+
580+
# With assignment.
581+
@model outer() = @submodel x = inner()
582+
@test outer()() isa Real
573583
end
574584
end

0 commit comments

Comments
 (0)