Seems to me that a good law would explain the spirit, and the purpose and rationale, so that an adjudicator (or police) can judge when and when not to apply it.
And when laws don’t explain those things, problems can and will happen.
I tend to think that unreasonable laws shouldn’t be laws, and shouldn’t be enforced. This is also often (but not often enough) practiced, where problematic and/or outdated laws are not enforced or are thrown out in court, or are enforced only when/if they makes sense and/or their spirit is followed.
But I also think that it is the obligation of legislators to write laws that explicitly cover the situations they want covered. So corrections for spirit should usually be in the favor of the defendant. i.e. sloppily written laws should lead to less enforcement than intended, but not more.