Closed mccordscvs closed 4 years ago
Thanks for reporting this. Indeed, there should not be a result for the negative line label.
However, I do not agree with reducing the severity level for On Error Goto -1
. First of all, this feature is undocumented for VBA. Moreover, it actually has undefined behaviour when used while error handling is not active.
The way you are supposed to exit error handling in VBA is to use Resume
, Resume Next
or Resume <label>
in order to jump back into the ordinary execution flow.
On Error GoTo 0
is more commonly used for that purpose, and is documented. On Error GoTo -1
is being legitimately flagged here (although, it shouldn't trigger the "negative line number" inspection).
Severity levels default to warning for most inspections; use inspection settings to configure them as you please - note that DoNotShow level effectively disables an inspection (i.e. it won't run at all).
Rubberduck version information
Description
The "On Error Goto -1" statement is triggering 2 inspections: "Negative Line Number Encountered", "On Error GoTo -1 Encountered". These Inspections are also at severality level Warning. GoTo -1 is the only way, that I know, to reset the Error Handler the err.Clear statement does not reset the error handler it just clears the error which is not the same thing.
Expected behavior The negative line number inspection should not be triggered. I believe that the severality level of "On Error GoTo -1" should be changed to Info or the inspection is not totally revmoved.
Screenshots