RESOLVED FIXED 155454
Destructuring parameters are evaluated in the wrong scope
https://bugs.webkit.org/show_bug.cgi?id=155454
Summary Destructuring parameters are evaluated in the wrong scope
Saam Barati
Reported 2016-03-14 13:21:42 PDT
i.e: return (function({a=function(){ return typeof b === 'undefined'; }}){ var b = 1; return a(); }({}));
Attachments
patch (18.20 KB, patch)
2016-03-14 15:39 PDT, Saam Barati
no flags
patch (22.31 KB, patch)
2016-03-14 16:42 PDT, Saam Barati
no flags
patch (22.55 KB, patch)
2016-03-14 16:44 PDT, Saam Barati
no flags
Saam Barati
Comment 1 2016-03-14 14:07:33 PDT
our computation of "isSimpleParameterList" is wrong.
Saam Barati
Comment 2 2016-03-14 15:39:15 PDT
WebKit Commit Bot
Comment 3 2016-03-14 15:41:25 PDT
Attachment 274041 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:838: Extra space before ( in function call [whitespace/parens] [4] Total errors found: 1 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Caitlin Potter (:caitp)
Comment 4 2016-03-14 16:04:51 PDT
I would suggest adding tests involving arrow functions and default parameters --- there were some similar bugs in V8's implementation in these contexts due to incorrect scoping issues. I'm not sure it affects JSC as well because of the different frontend approach, but it probably doesn't hurt to pass similar tests. https://github.com/v8/v8/blob/02e4d21f4ce799c7d4e3500fa2cf96fc447456ff/test/mjsunit/harmony/regress/regress-4395.js
Saam Barati
Comment 5 2016-03-14 16:07:39 PDT
(In reply to comment #4) > I would suggest adding tests involving arrow functions and default > parameters --- there were some similar bugs in V8's implementation in these > contexts due to incorrect scoping issues. > > I'm not sure it affects JSC as well because of the different frontend > approach, but it probably doesn't hurt to pass similar tests. > https://github.com/v8/v8/blob/02e4d21f4ce799c7d4e3500fa2cf96fc447456ff/test/ > mjsunit/harmony/regress/regress-4395.js Will do. Thanks.
Saam Barati
Comment 6 2016-03-14 16:42:47 PDT
Created attachment 274049 [details] patch added the v8 tests.
WebKit Commit Bot
Comment 7 2016-03-14 16:44:05 PDT
Attachment 274049 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:838: Extra space before ( in function call [whitespace/parens] [4] Total errors found: 1 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Saam Barati
Comment 8 2016-03-14 16:44:16 PDT
Saam Barati
Comment 9 2016-03-14 16:44:42 PDT
Comment on attachment 274050 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=274050&action=review > Source/JavaScriptCore/tests/stress/v8-parameter-scoping.js:26 > +// Copyright 2014, the V8 project authors. All rights reserved. > +// Redistribution and use in source and binary forms, with or without > +// modification, are permitted provided that the following conditions are > +// met: > +// > +// * Redistributions of source code must retain the above copyright > +// notice, this list of conditions and the following disclaimer. > +// * Redistributions in binary form must reproduce the above > +// copyright notice, this list of conditions and the following > +// disclaimer in the documentation and/or other materials provided > +// with the distribution. > +// * Neither the name of Google Inc. nor the names of its > +// contributors may be used to endorse or promote products derived > +// from this software without specific prior written permission. > +// > +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS > +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT > +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR > +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT > +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, > +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT > +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE > +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Is this ok?
WebKit Commit Bot
Comment 10 2016-03-14 16:46:40 PDT
Attachment 274050 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:838: Extra space before ( in function call [whitespace/parens] [4] Total errors found: 1 in 6 files If any of these errors are false positives, please file a bug against check-webkit-style.
Caitlin Potter (:caitp)
Comment 11 2016-03-14 17:31:49 PDT
I'm not a lawyer, but it matches the license text, so lgtm
Filip Pizlo
Comment 12 2016-03-14 17:35:59 PDT
(In reply to comment #9) > Comment on attachment 274050 [details] > patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=274050&action=review > > > Source/JavaScriptCore/tests/stress/v8-parameter-scoping.js:26 > > +// Copyright 2014, the V8 project authors. All rights reserved. > > +// Redistribution and use in source and binary forms, with or without > > +// modification, are permitted provided that the following conditions are > > +// met: > > +// > > +// * Redistributions of source code must retain the above copyright > > +// notice, this list of conditions and the following disclaimer. > > +// * Redistributions in binary form must reproduce the above > > +// copyright notice, this list of conditions and the following > > +// disclaimer in the documentation and/or other materials provided > > +// with the distribution. > > +// * Neither the name of Google Inc. nor the names of its > > +// contributors may be used to endorse or promote products derived > > +// from this software without specific prior written permission. > > +// > > +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS > > +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT > > +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR > > +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT > > +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, > > +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT > > +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > > +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > > +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > > +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE > > +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > > Is this ok? Looks like BSD 3-clause to me, so I think that it's fine.
Geoffrey Garen
Comment 13 2016-03-14 20:26:26 PDT
Comment on attachment 274050 [details] patch r=me
WebKit Commit Bot
Comment 14 2016-03-15 01:58:47 PDT
Comment on attachment 274050 [details] patch Clearing flags on attachment: 274050 Committed r198206: <http://trac.webkit.org/changeset/198206>
WebKit Commit Bot
Comment 15 2016-03-15 01:58:52 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.