@@ -239,50 +239,51 @@ function DynamicPPL.setchildcontext(context::DebugContext, child)
239
239
end
240
240
241
241
function record_varname! (context:: DebugContext , varname:: VarName , dist)
242
- if haskey (context. varnames_seen, varname)
242
+ prefixed_varname = prefix (context, varname)
243
+ if haskey (context. varnames_seen, prefixed_varname)
243
244
if context. error_on_failure
244
- error (" varname $varname used multiple times in model" )
245
+ error (" varname $prefixed_varname used multiple times in model" )
245
246
else
246
- @warn " varname $varname used multiple times in model"
247
+ @warn " varname $prefixed_varname used multiple times in model"
247
248
end
248
- context. varnames_seen[varname ] += 1
249
+ context. varnames_seen[prefixed_varname ] += 1
249
250
else
250
251
# We need to check:
251
252
# 1. Does this `varname` subsume any of the other keys.
252
253
# 2. Does any of the other keys subsume `varname`.
253
254
vns = collect (keys (context. varnames_seen))
254
255
# Is `varname` subsumed by any of the other keys?
255
- idx_parent = findfirst (Base. Fix2 (subsumes, varname ), vns)
256
+ idx_parent = findfirst (Base. Fix2 (subsumes, prefixed_varname ), vns)
256
257
if idx_parent != = nothing
257
258
varname_parent = vns[idx_parent]
258
259
if context. error_on_failure
259
260
error (
260
- " varname $(varname_parent) used multiple times in model (subsumes $varname )" ,
261
+ " varname $(varname_parent) used multiple times in model (subsumes $prefixed_varname )" ,
261
262
)
262
263
else
263
- @warn " varname $(varname_parent) used multiple times in model (subsumes $varname )"
264
+ @warn " varname $(varname_parent) used multiple times in model (subsumes $prefixed_varname )"
264
265
end
265
266
# Update count of parent.
266
267
context. varnames_seen[varname_parent] += 1
267
268
else
268
269
# Does `varname` subsume any of the other keys?
269
- idx_child = findfirst (Base. Fix1 (subsumes, varname ), vns)
270
+ idx_child = findfirst (Base. Fix1 (subsumes, prefixed_varname ), vns)
270
271
if idx_child != = nothing
271
272
varname_child = vns[idx_child]
272
273
if context. error_on_failure
273
274
error (
274
- " varname $(varname_child) used multiple times in model (subsumed by $varname )" ,
275
+ " varname $(varname_child) used multiple times in model (subsumed by $prefixed_varname )" ,
275
276
)
276
277
else
277
- @warn " varname $(varname_child) used multiple times in model (subsumed by $varname )"
278
+ @warn " varname $(varname_child) used multiple times in model (subsumed by $prefixed_varname )"
278
279
end
279
280
280
281
# Update count of child.
281
282
context. varnames_seen[varname_child] += 1
282
283
end
283
284
end
284
285
285
- context. varnames_seen[varname ] = 1
286
+ context. varnames_seen[prefixed_varname ] = 1
286
287
end
287
288
end
288
289
0 commit comments