The root cause is that a hover evaluation's scope is being misidentified
as happening in a scope above the one it should actually run in. We then
saw this and thought we should hoist a variable, but don't find a
variable to hoist, and leave the replaced identifier in the expression.
If the scope were not misidentified, then the behavior would have been
identical because the variable would not be defined anyway.
In this PR we replace the identifier back to its original if we don't
find a variable to hoist, and also add logging to help any future
issues.
I haven't been quite able to reproduce this, but this is the explaination I see for https://github.com/microsoft/vscode/issues/221503, plausibly caused by sourcemap funkiness.
The root cause is that a hover evaluation's scope is being misidentified as happening in a scope above the one it should actually run in. We then saw this and thought we should hoist a variable, but don't find a variable to hoist, and leave the replaced identifier in the expression. If the scope were not misidentified, then the behavior would have been identical because the variable would not be defined anyway.
In this PR we replace the identifier back to its original if we don't find a variable to hoist, and also add logging to help any future issues.