"Remove debug" refactoring fails
The Remove debug refactoring doesnt seem to remove debugs! They had the form of “something”.
Submitted by André Vieira on 15 November 2011 at 10:28
Issue Log
do you have a concrete example where it did not work?
rules
rename: Block(ss) -> Block(ss') where <debug> "a" ; new-scope( ss' := <analyse> ss )
(adapted analysis.str in the org.spoofax.examples.pl project)
remove debug refactoring removes debug calls that can savely be removed as in: "x := 4 ; debug(!"x: “)”. in this case, the “a” constructs the term “a” so it is not easy to see if it can be removed savely.
possible solutions: 1) keep debug, 2) remove but report as error/warning, 3) replace with or ! (seems a bad idea), 4) try to do a more refined analysis (probably difficult)
The example is not a bug. Removing the debug statement, will apply new-scope to Block(ss). Without a removal, it is applied to “a”. This is crucial for new-scope, as it creates dynamic rules capturing knowledge about the current scope.
Maybe the refactoring should give a warning or something for debug statements that change the current term?
So I guess the best idea is to keep the debug but report warnings, like: “line 5: debug could not be removed”
The error message should explain why it cannot be removed, e.g. “line 5: debug statement changes current term and cannot be removed”
Log in to post comments