Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# DynamicPPL Changelog

## 0.38.7

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).

## 0.38.6

Renamed keyword argument `only_ddpl` to `only_dppl` for `Experimental.is_suitable_varinfo`.
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "DynamicPPL"
uuid = "366bfd00-2699-11ea-058f-f148b4cae6d8"
version = "0.38.6"
version = "0.38.7"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
13 changes: 10 additions & 3 deletions src/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,16 @@ function generate_tilde(left, right)
elseif $isassumption
$(generate_tilde_assume(left, dist, vn))
else
# If `vn` is not in `argnames`, we need to make sure that the variable is defined.
if !$(DynamicPPL.inargnames)($vn, __model__)
$left = $(DynamicPPL.getconditioned_nested)(
# If `vn` is not in `argnames`, then it's definitely been conditioned on (if
# it's not in `argnames` and wasn't conditioned on, then `isassumption` would
# be true).
$left = if $(DynamicPPL.inargnames)($vn, __model__)
# This is a no-op and looks redundant, but defining the compiler output this
# way ensures that the variable `$left` is always defined. See
# https://github.com/TuringLang/DynamicPPL.jl/pull/1110.
$left
else
$(DynamicPPL.getconditioned_nested)(
__model__.context, $(DynamicPPL.prefix)(__model__.context, $vn)
)
end
Expand Down