Prevent spurious error hints #164
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The error hint for
MethodError
(see #146) is indiscriminate in that it catches anyMethodError
. We can't do much about that, but we can try to restrict it to MethodErrors which only involve one of the arguments being aLogDensityModel
.AbstractMCMC.jl/src/AbstractMCMC.jl
Lines 123 to 135 in ececa17
Unfortunately,
Base.parentmodule
is not defined for callable structs, so if you called a callable struct with the wrong arguments and you happened to have AbstractMCMC in your environment, this error hint would try to take over and would itself error. I discovered this when calling(::DynamicPPL.Model)(args...)
with the wrong combination of arguments.This PR fixes it by (1) reversing the order of checks, so that it shortcircuits if none of the arguments are
LogDensityModel
s; and also (2) explicitly checking thatexc.f
is a function, because the things we want to catch areLogDensityProblems.foo
which are indeed functions. Both together might be a bit overkill, but anyway.