with statement can't get along with spread operator
Reported by
hinass...@gmail.com,
Dec 9 2017
|
||||
Issue description
UserAgent: Mozilla/5.0 (X11; CrOS x86_64 9901.77.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.97 Safari/537.36
Platform: 9901.77.0 (Official Build) stable-channel sentry
Steps to reproduce the problem:
Evaluate the following:
with ({ f : function () { return this } }) f(...[1], 5)
This is evaluated to [Windows] i.e. global scope.
What is the expected behavior?
Expected to be evaluated in the same way as
with ({ f : function () { return this } }) f(1, 5)
This is evaluated to { f : function () { return this } }.
What went wrong?
semantic inconsistency
Did this work before? N/A
Chrome version: 62.0.3202.97 Channel: stable
OS Version: 9901.77.0
Flash Version:
,
Dec 19 2017
Should this even work?
,
Dec 19 2017
I’d expect the `{ f: … }` object as the result, not the global object. Other engines implement this correctly:
$ eshost -e '(() => { with ({ f: function() { return this; } }) print(f(...[1], 2)); })()'
#### Chakra
[object Object]
undefined
#### JavaScriptCore
[object Object]
undefined
#### SpiderMonkey
[object Object]
undefined
#### V8 --harmony
[object global]
undefined
#### V8
[object global]
undefined
$ eshost -e '(() => { with ({ f: function() { return this; } }) print(f(...[1], 2).f); })()'
#### Chakra
function () { return this; }
undefined
#### JavaScriptCore
function () { return this; }
undefined
#### SpiderMonkey
function() { return this; }
undefined
#### V8 --harmony
undefined
undefined
#### V8
undefined
undefined
When the second argument is removed, V8 behaves as expected.
,
Dec 19 2017
This is because spread calls which feature arguments after the spread are desugared into a call to Reflect.apply, and it has no access to the `with` context to be able to fill in the correct receiver. (changing to "Assigned", since this has an owner, but gsathya, feel free to unassign an re-mark this as "Available" if desired). |
||||
►
Sign in to add a comment |
||||
Comment 1 by rbyers@chromium.org
, Dec 9 2017