ericmckean / traceur-compiler

Automatically exported from code.google.com/p/traceur-compiler
Apache License 2.0
0 stars 0 forks source link

'with' scopes missing from FreeVariableChecker #207

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
in repl:

---
var obj = {
  x: 4
};

function foo() {
  with(obj) {
    x = 1;
    console.log('x is ' + x);
  }
}
foo();

---
fails with 
repl:7:4: x is not defined
but devtools console gives 
x is 1

Original issue reported on code.google.com by johnjbar...@chromium.org on 27 Feb 2013 at 8:31

GoogleCodeExporter commented 9 years ago
Looks like the only thing to do is to turn off var checking
inside 'with'. Reminds me of why 'with' is such a messy
piece of syntax.

There is no general way to statically analyze code and
decide if 'x' is a member of 'obj'.

Original comment by usrbi...@yahoo.com on 28 Feb 2013 at 9:33