-
Notifications
You must be signed in to change notification settings - Fork 0
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
6afe558
commit c2cff73
Showing
1 changed file
with
52 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,52 @@ | ||
# TODO | ||
|
||
* 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 | ||
* Tests for `with` in `eval()` | ||
* Tests for `this` where implicitly used by `super()` and `super` | ||
|
||
* Fix proxy preventing correct `this` being passed to method calls | ||
|
||
This prints 'true' in original, but 'false' once instrumented: | ||
|
||
```js | ||
const obj = { | ||
foo() { | ||
console.log(this === obj); | ||
} | ||
}; | ||
with (obj) { | ||
foo(); | ||
} | ||
``` | ||
|
||
This should print '1,2,3' but prints '[object Undefined]': | ||
|
||
```js | ||
with ([1, 2, 3]) { | ||
console.log(toString()); | ||
} | ||
``` | ||
|
||
Also affects primitives: | ||
|
||
```js | ||
with (123) { | ||
console.log(toString()); | ||
} | ||
``` | ||
|
||
Should print '123', but instead throws error. The proxy that `with` expression is replaced with is passed to `Number.prototype.toString` as `this` and it throws `TypeError: Number.prototype.toString requires that 'this' be a Number`. | ||
|
||
* Raise Github issue for 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; }; | ||
} | ||
``` |