Skip to content

Commit 2ad7d54

Browse files
committed
Fix potential undefined variable in model compiler output
1 parent 8c34394 commit 2ad7d54

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# DynamicPPL Changelog
22

3+
## 0.38.5
4+
5+
Made a small tweak to DynamicPPL's compiler output to avoid potential undefined variables when resuming model functions midway through (e.g. with Libtask in Turing's SMC/PG samplers).
6+
37
## 0.38.4
48

59
Improve performance of VarNamedVector. It should now be very nearly on par with Metadata for all models we've benchmarked on.

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DynamicPPL"
22
uuid = "366bfd00-2699-11ea-058f-f148b4cae6d8"
3-
version = "0.38.4"
3+
version = "0.38.5"
44

55
[deps]
66
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

src/compiler.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,12 @@ function generate_tilde(left, right)
462462
$(generate_tilde_assume(left, dist, vn))
463463
else
464464
# If `vn` is not in `argnames`, we need to make sure that the variable is defined.
465-
if !$(DynamicPPL.inargnames)($vn, __model__)
466-
$left = $(DynamicPPL.getconditioned_nested)(
465+
$left = if !$(DynamicPPL.inargnames)($vn, __model__)
466+
$(DynamicPPL.getconditioned_nested)(
467467
__model__.context, $(DynamicPPL.prefix)(__model__.context, $vn)
468468
)
469+
else
470+
$left
469471
end
470472

471473
$value, __varinfo__ = $(DynamicPPL.tilde_observe!!)(

0 commit comments

Comments
 (0)