@@ -175,6 +175,9 @@ function unwrap_right_left_vns(
175
175
return unwrap_right_left_vns (right, left, vns)
176
176
end
177
177
178
+ resolve_varnames (vn:: VarName , _) = vn
179
+ resolve_varnames (vn:: VarName , dist:: NamedDist ) = dist. name
180
+
178
181
# ################
179
182
# Main Compiler #
180
183
# ################
@@ -379,16 +382,19 @@ function generate_tilde(left, right)
379
382
380
383
# Otherwise it is determined by the model or its value,
381
384
# if the LHS represents an observation
382
- @gensym vn isassumption value
385
+ @gensym vn isassumption value dist
383
386
384
387
# HACK: Usage of `drop_escape` is unfortunate. It's a consequence of the fact
385
388
# that in DynamicPPL we the entire function body. Instead we should be
386
389
# more selective with our escape. Until that's the case, we remove them all.
387
390
return quote
388
- $ vn = $ (AbstractPPL. drop_escape (varname (left)))
391
+ $ dist = $ right
392
+ $ vn = $ (DynamicPPL. resolve_varnames)(
393
+ $ (AbstractPPL. drop_escape (varname (left))), $ dist
394
+ )
389
395
$ isassumption = $ (DynamicPPL. isassumption (left, vn))
390
396
if $ isassumption
391
- $ (generate_tilde_assume (left, right , vn))
397
+ $ (generate_tilde_assume (left, dist , vn))
392
398
else
393
399
# If `vn` is not in `argnames`, we need to make sure that the variable is defined.
394
400
if ! $ (DynamicPPL. inargnames)($ vn, __model__)
@@ -397,7 +403,7 @@ function generate_tilde(left, right)
397
403
398
404
$ value, __varinfo__ = $ (DynamicPPL. tilde_observe!!)(
399
405
__context__,
400
- $ (DynamicPPL. check_tilde_rhs)($ right ),
406
+ $ (DynamicPPL. check_tilde_rhs)($ dist ),
401
407
$ (maybe_view (left)),
402
408
$ vn,
403
409
__varinfo__,
@@ -442,7 +448,9 @@ function generate_dot_tilde(left, right)
442
448
# if the LHS represents an observation
443
449
@gensym vn isassumption value
444
450
return quote
445
- $ vn = $ (AbstractPPL. drop_escape (varname (left)))
451
+ $ vn = $ (DynamicPPL. resolve_varnames)(
452
+ $ (AbstractPPL. drop_escape (varname (left))), $ right
453
+ )
446
454
$ isassumption = $ (DynamicPPL. isassumption (left, vn))
447
455
if $ isassumption
448
456
$ (generate_dot_tilde_assume (left, right, vn))
0 commit comments