Skip to content

Commit aaf0bc6

Browse files
committed
Add error hint for three-argument evaluate!!
1 parent bfa48b3 commit aaf0bc6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/DynamicPPL.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,21 @@ if isdefined(Base.Experimental, :register_error_hint)
226226
)
227227
end
228228
end
229+
230+
Base.Experimental.register_error_hint(MethodError) do io, exc, argtypes, _
231+
is_evaluate_three_arg =
232+
exc.f === AbstractPPL.evaluate!! &&
233+
length(argtypes) == 3 &&
234+
argtypes[1] <: Model &&
235+
argtypes[2] <: AbstractVarInfo &&
236+
argtypes[3] <: AbstractContext
237+
if is_evaluate_three_arg
238+
print(
239+
io,
240+
"\n\nThe method `evaluate!!(model, varinfo, new_ctx)` has been removed. Instead, you should store the `new_ctx` in the `model.context` field using `new_model = contextualize(model, new_ctx)`, and then call `evaluate!!(new_model, varinfo)` on the new model. (Note that, if the model already contained a non-default context, you will need to wrap the existing context.)",
241+
)
242+
end
243+
end
229244
end
230245
end
231246

0 commit comments

Comments
 (0)