You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
escope thinks that the v inside the try block is in the global scope:
varlocal_v;try{global_v=1;}catch(e){}
I discovered this when I tried to use escope to refactor a try...catch and found that the code broke because the code inside the try was still using the old variable name.
Here is a test case which does not pass:
expect=require('chai').expectesprima=require'esprima'escope=require'..'describe'try', ->it'finds a variable in the parent scope', ->ast=esprima.parse""" var v; try { v = 1; } catch(e) {}"""scopeManager=escope.analyze ast
globalScope=scopeManager.scopes[0]
expect(globalScope.type).to.be.equal'global'expect(globalScope.variables).to.have.length0expect(globalScope.references).to.have.length0
I believe this is related to #57 but I'm not certain.
The text was updated successfully, but these errors were encountered:
The problem is that the identifier v is viewed as having two different scopes, one inside the try and one outside of it. However it's the same v in both places.
Given the following JavaScript:
escope thinks that the
v
inside thetry
block is in the global scope:I discovered this when I tried to use escope to refactor a try...catch and found that the code broke because the code inside the try was still using the old variable name.
Here is a test case which does not pass:
I believe this is related to #57 but I'm not certain.
The text was updated successfully, but these errors were encountered: