-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
90c517e
commit 499526c
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# TODO | ||
|
||
* I think `arguments` needs to be added to reserved var names set if it's used in a function as an internal var, and also set as `isFrozenInternal` | ||
* Tests | ||
* Test for `"use strict"` directive in function not being moved up to outside `with ()` | ||
* Test for multiple `with ()`s between var and its binding | ||
* Test for `with ()` with no `{}` statement block | ||
* TODO comments | ||
* Deal with `with` in `eval()` - or is this done already? | ||
|
||
* Freeze `this` | ||
|
||
Mostly fixed now (except where `this` implicitly used by `super`) but needs tests. | ||
|
||
e.g. this produces wrong result: | ||
|
||
```js | ||
function f() { | ||
with ({y: 1, this$0: {x: 2}}) { | ||
return () => y + this.x; | ||
} | ||
} | ||
module.exports = f.call({x: 1}); | ||
``` | ||
|
||
produces: | ||
|
||
```js | ||
module.exports = (this$0 => with$0 => { | ||
with (with$0) return () => y + this$0.x; | ||
})({x: 1})({y: 1, this$0: {x: 2}}); | ||
``` | ||
|
||
* Fix `arguments`. e.g.: | ||
|
||
Now fixed I think, but need tests. | ||
|
||
```js | ||
function f() { | ||
with ({}) { | ||
return () => arguments[0]; | ||
} | ||
} | ||
module.exports = f(1); | ||
``` | ||
|
||
produces: | ||
|
||
```js | ||
module.exports = (_arguments => (() => with$0 => { | ||
with (with$0) return () => arguments[0]; | ||
}).apply(0, _arguments))(function () { | ||
return arguments; | ||
}(1))({}); | ||
``` | ||
|
||
Problem is `() => with$0` needs to be a full function `function () { return with$0 => { ... } }`. | ||
|
||
* Support interaction with const violations | ||
|
||
e.g. How to deal with this? Whether `x = 2` is a const violation depends on whether `obj` has a property called `x` or not. | ||
|
||
```js | ||
const x = 1; | ||
with (obj) { | ||
module.exports = () => { x = 2; }; | ||
} | ||
``` |