Rubberduck: Code Inspection to fix by changing function to sub error

Created on 7 Nov 2018  路  2Comments  路  Source: rubberduck-vba/Rubberduck

Fixing left the (supposed to be removed End Function) and put the End Sub before the (not removed) End Function causing a compile error.
Before Fix

Private Function Foo(arglist)
End Function

After Fix

Private Sub Foo(arglist)
   End Sub
End Function

Don't know if it matters, but the Function that was to be fixed is the last one in the module.

bug difficulty-03-duck feature-inspection-quickfixes feature-inspections status-norepro up-for-grabs

Most helpful comment

I cannot reproduce this error applying the quickfix immediately after the inspection result got created.

Did you do anything between generating the inspection result and applying the quickfix? Here a setting might play a role: do you have running the inspections after parsing disabled in the settings?

With this disabled I can reproduce the issue by running the inspections, then adding a new line with some whitespace, parsing and then choosing to apply the fix to the inspection.

All 2 comments

The ConvertToProcedureQuickFix is correctly replacing the FUNCTION and END_FUNCTION tokens of the FunctionStmtContext with SUB and END_SUB tokens, respectively; this isn't as trivial as it seems - it would have been, had this quickfix not been leveraging the rewriter API.

I cannot reproduce this error applying the quickfix immediately after the inspection result got created.

Did you do anything between generating the inspection result and applying the quickfix? Here a setting might play a role: do you have running the inspections after parsing disabled in the settings?

With this disabled I can reproduce the issue by running the inspections, then adding a new line with some whitespace, parsing and then choosing to apply the fix to the inspection.

Was this page helpful?
0 / 5 - 0 ratings