<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[203263] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/203263">203263</a></dd>
<dt>Author</dt> <dd>sbarati@apple.com</dd>
<dt>Date</dt> <dd>2016-07-14 19:11:42 -0700 (Thu, 14 Jul 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>It should be a syntax error to have a 'use strict' directive inside a function that has a non-simple parameter list
https://bugs.webkit.org/show_bug.cgi?id=159790
&lt;rdar://problem/27171636&gt;

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Is is a syntax error for a function's parameter list to be non-simple
and for the function to also contain a 'use strict' directive.

See section 14.2.1 of the spec:
https://tc39.github.io/ecma262/#sec-arrow-function-definitions-static-semantics-early-errors

* parser/Parser.cpp:
(JSC::Parser&lt;LexerType&gt;::parseSourceElements):
(JSC::Parser&lt;LexerType&gt;::parseFormalParameters):
* parser/Parser.h:
(JSC::Scope::Scope):
(JSC::Scope::strictMode):
(JSC::Scope::isValidStrictMode):
(JSC::Scope::shadowsArguments):
(JSC::Scope::setHasNonSimpleParameterList):
(JSC::Scope::hasNonSimpleParameterList):
(JSC::Scope::copyCapturedVariablesToVector):

LayoutTests:

* js/parser-syntax-check-expected.txt:
* js/script-tests/parser-syntax-check.js:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsjsparsersyntaxcheckexpectedtxt">trunk/LayoutTests/js/parser-syntax-check-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsparsersyntaxcheckjs">trunk/LayoutTests/js/script-tests/parser-syntax-check.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserParsercpp">trunk/Source/JavaScriptCore/parser/Parser.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserParserh">trunk/Source/JavaScriptCore/parser/Parser.h</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstresses6defaultparametersjs">trunk/Source/JavaScriptCore/tests/stress/es6-default-parameters.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressreflectsetjs">trunk/Source/JavaScriptCore/tests/stress/reflect-set.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (203262 => 203263)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-07-15 02:07:45 UTC (rev 203262)
+++ trunk/LayoutTests/ChangeLog        2016-07-15 02:11:42 UTC (rev 203263)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-07-14  Saam Barati  &lt;sbarati@apple.com&gt;
+
+        It should be a syntax error to have a 'use strict' directive inside a function that has a non-simple parameter list
+        https://bugs.webkit.org/show_bug.cgi?id=159790
+        &lt;rdar://problem/27171636&gt;
+
+        Reviewed by Geoffrey Garen.
+
+        * js/parser-syntax-check-expected.txt:
+        * js/script-tests/parser-syntax-check.js:
+
</ins><span class="cx"> 2016-07-14  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS WK2] When scrolling apple.com/music on iPad Pro in landscape, left-hand tiles appear first
</span></span></pre></div>
<a id="trunkLayoutTestsjsparsersyntaxcheckexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/parser-syntax-check-expected.txt (203262 => 203263)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/parser-syntax-check-expected.txt        2016-07-15 02:07:45 UTC (rev 203262)
+++ trunk/LayoutTests/js/parser-syntax-check-expected.txt        2016-07-15 02:11:42 UTC (rev 203263)
</span><span class="lines">@@ -1156,6 +1156,99 @@
</span><span class="cx"> PASS Invalid: &quot;function f() { 'use strict'; function foo(...yield) { } }&quot;
</span><span class="cx"> PASS Invalid: &quot;function foo(...if) { }&quot;
</span><span class="cx"> PASS Invalid: &quot;function f() { function foo(...if) { } }&quot;
</span><ins>+non-simple parameter list
+PASS Invalid: &quot;function foo(...restParam) { 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { function foo(...restParam) { 'use strict'; } }&quot;
+PASS Invalid: &quot;function foo(...restParam) { 'a'; 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { function foo(...restParam) { 'a'; 'use strict'; } }&quot;
+PASS Invalid: &quot;function foo({x}) { 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { function foo({x}) { 'use strict'; } }&quot;
+PASS Invalid: &quot;function foo({x}) { 'a'; 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { function foo({x}) { 'a'; 'use strict'; } }&quot;
+PASS Invalid: &quot;function foo(a = 20) { 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { function foo(a = 20) { 'use strict'; } }&quot;
+PASS Invalid: &quot;function foo(a = 20) { 'a'; 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { function foo(a = 20) { 'a'; 'use strict'; } }&quot;
+PASS Invalid: &quot;function foo({a} = 20) { 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { function foo({a} = 20) { 'use strict'; } }&quot;
+PASS Invalid: &quot;function foo({a} = 20) { 'a'; 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { function foo({a} = 20) { 'a'; 'use strict'; } }&quot;
+PASS Invalid: &quot;function foo([a]) { 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { function foo([a]) { 'use strict'; } }&quot;
+PASS Invalid: &quot;function foo([a]) { 'a'; 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { function foo([a]) { 'a'; 'use strict'; } }&quot;
+PASS Invalid: &quot;function foo(foo, bar, a = 25) { 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { function foo(foo, bar, a = 25) { 'use strict'; } }&quot;
+PASS Invalid: &quot;function foo(foo, bar, a = 25) { 'a'; 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { function foo(foo, bar, a = 25) { 'a'; 'use strict'; } }&quot;
+PASS Invalid: &quot;function foo(foo, bar, baz, ...rest) { 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { function foo(foo, bar, baz, ...rest) { 'use strict'; } }&quot;
+PASS Invalid: &quot;function foo(foo, bar, baz, ...rest) { 'a'; 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { function foo(foo, bar, baz, ...rest) { 'a'; 'use strict'; } }&quot;
+PASS Invalid: &quot;function foo(a = function() { }) { 'use strict'; a(); }&quot;
+PASS Invalid: &quot;function f() { function foo(a = function() { }) { 'use strict'; a(); } }&quot;
+PASS Invalid: &quot;function foo(a = function() { }) { 'a'; 'use strict'; a(); }&quot;
+PASS Invalid: &quot;function f() { function foo(a = function() { }) { 'a'; 'use strict'; a(); } }&quot;
+PASS Invalid: &quot;let foo = (...restParam) =&gt; { 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { let foo = (...restParam) =&gt; { 'use strict'; } }&quot;
+PASS Invalid: &quot;let foo = (...restParam) =&gt; { 'a'; 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { let foo = (...restParam) =&gt; { 'a'; 'use strict'; } }&quot;
+PASS Invalid: &quot;let foo = ({x}) =&gt; { 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { let foo = ({x}) =&gt; { 'use strict'; } }&quot;
+PASS Invalid: &quot;let foo = ({x}) =&gt; { 'a'; 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { let foo = ({x}) =&gt; { 'a'; 'use strict'; } }&quot;
+PASS Invalid: &quot;let foo = (a = 20) =&gt; { 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { let foo = (a = 20) =&gt; { 'use strict'; } }&quot;
+PASS Invalid: &quot;let foo = (a = 20) =&gt; { 'a'; 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { let foo = (a = 20) =&gt; { 'a'; 'use strict'; } }&quot;
+PASS Invalid: &quot;let foo = ({a} = 20) =&gt; { 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { let foo = ({a} = 20) =&gt; { 'use strict'; } }&quot;
+PASS Invalid: &quot;let foo = ({a} = 20) =&gt; { 'a'; 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { let foo = ({a} = 20) =&gt; { 'a'; 'use strict'; } }&quot;
+PASS Invalid: &quot;let foo = ([a]) =&gt; { 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { let foo = ([a]) =&gt; { 'use strict'; } }&quot;
+PASS Invalid: &quot;let foo = ([a]) =&gt; { 'a'; 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { let foo = ([a]) =&gt; { 'a'; 'use strict'; } }&quot;
+PASS Invalid: &quot;let foo = (foo, bar, a = 25) =&gt; { 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { let foo = (foo, bar, a = 25) =&gt; { 'use strict'; } }&quot;
+PASS Invalid: &quot;let foo = (foo, bar, a = 25) =&gt; { 'a'; 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { let foo = (foo, bar, a = 25) =&gt; { 'a'; 'use strict'; } }&quot;
+PASS Invalid: &quot;let foo = (foo, bar, baz, ...rest) =&gt; { 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { let foo = (foo, bar, baz, ...rest) =&gt; { 'use strict'; } }&quot;
+PASS Invalid: &quot;let foo = (foo, bar, baz, ...rest) =&gt; { 'a'; 'use strict'; }&quot;
+PASS Invalid: &quot;function f() { let foo = (foo, bar, baz, ...rest) =&gt; { 'a'; 'use strict'; } }&quot;
+PASS Invalid: &quot;let foo = (a = function() { }) =&gt; { 'use strict'; a(); }&quot;
+PASS Invalid: &quot;function f() { let foo = (a = function() { }) =&gt; { 'use strict'; a(); } }&quot;
+PASS Invalid: &quot;let foo = (a = function() { }) =&gt; { 'a'; 'use strict'; a(); }&quot;
+PASS Invalid: &quot;function f() { let foo = (a = function() { }) =&gt; { 'a'; 'use strict'; a(); } }&quot;
+PASS Valid:   &quot;function outer() { 'use strict'; function foo(...restParam) {  } }&quot;
+PASS Valid:   &quot;function f() { function outer() { 'use strict'; function foo(...restParam) {  } } }&quot;
+PASS Valid:   &quot;function outer() { 'use strict'; function foo(a,b,c,...restParam) {  } }&quot;
+PASS Valid:   &quot;function f() { function outer() { 'use strict'; function foo(a,b,c,...restParam) {  } } }&quot;
+PASS Valid:   &quot;function outer() { 'use strict'; function foo(a = 20,b,c,...restParam) {  } }&quot;
+PASS Valid:   &quot;function f() { function outer() { 'use strict'; function foo(a = 20,b,c,...restParam) {  } } }&quot;
+PASS Valid:   &quot;function outer() { 'use strict'; function foo(a = 20,{b},c,...restParam) {  } }&quot;
+PASS Valid:   &quot;function f() { function outer() { 'use strict'; function foo(a = 20,{b},c,...restParam) {  } } }&quot;
+PASS Valid:   &quot;function outer() { 'use strict'; function foo(a = 20,{b},[c] = 5,...restParam) {  } }&quot;
+PASS Valid:   &quot;function f() { function outer() { 'use strict'; function foo(a = 20,{b},[c] = 5,...restParam) {  } } }&quot;
+PASS Valid:   &quot;function outer() { 'use strict'; function foo(a = 20) {  } }&quot;
+PASS Valid:   &quot;function f() { function outer() { 'use strict'; function foo(a = 20) {  } } }&quot;
+PASS Valid:   &quot;function outer() { 'use strict'; function foo(a,b,c,{d} = 20) {  } }&quot;
+PASS Valid:   &quot;function f() { function outer() { 'use strict'; function foo(a,b,c,{d} = 20) {  } } }&quot;
+PASS Invalid: &quot;function outer() { 'use strict'; function foo(...restParam) { 'use strict';  } }&quot;
+PASS Invalid: &quot;function f() { function outer() { 'use strict'; function foo(...restParam) { 'use strict';  } } }&quot;
+PASS Invalid: &quot;function outer() { 'use strict'; function foo(a,b,c,...restParam) {  'use strict'; } }&quot;
+PASS Invalid: &quot;function f() { function outer() { 'use strict'; function foo(a,b,c,...restParam) {  'use strict'; } } }&quot;
+PASS Invalid: &quot;function outer() { 'use strict'; function foo(a = 20,b,c,...restParam) {  'use strict'; } }&quot;
+PASS Invalid: &quot;function f() { function outer() { 'use strict'; function foo(a = 20,b,c,...restParam) {  'use strict'; } } }&quot;
+PASS Invalid: &quot;function outer() { 'use strict'; function foo(a = 20,{b},c,...restParam) { 'use strict'; } }&quot;
+PASS Invalid: &quot;function f() { function outer() { 'use strict'; function foo(a = 20,{b},c,...restParam) { 'use strict'; } } }&quot;
+PASS Invalid: &quot;function outer() { 'use strict'; function foo(a = 20,{b},[c] = 5,...restParam) { 'use strict'; } }&quot;
+PASS Invalid: &quot;function f() { function outer() { 'use strict'; function foo(a = 20,{b},[c] = 5,...restParam) { 'use strict'; } } }&quot;
+PASS Invalid: &quot;function outer() { 'use strict'; function foo(a = 20) {  'use strict';} }&quot;
+PASS Invalid: &quot;function f() { function outer() { 'use strict'; function foo(a = 20) {  'use strict';} } }&quot;
+PASS Invalid: &quot;function outer() { 'use strict'; function foo(a,b,c,{d} = 20) { 'use strict'; } }&quot;
+PASS Invalid: &quot;function f() { function outer() { 'use strict'; function foo(a,b,c,{d} = 20) { 'use strict'; } } }&quot;
</ins><span class="cx"> Arrow function
</span><span class="cx"> PASS Valid:   &quot;var x = (x) =&gt; x;&quot;
</span><span class="cx"> PASS Valid:   &quot;function f() { var x = (x) =&gt; x; }&quot;
</span></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsparsersyntaxcheckjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/script-tests/parser-syntax-check.js (203262 => 203263)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/parser-syntax-check.js        2016-07-15 02:07:45 UTC (rev 203262)
+++ trunk/LayoutTests/js/script-tests/parser-syntax-check.js        2016-07-15 02:11:42 UTC (rev 203263)
</span><span class="lines">@@ -688,6 +688,54 @@
</span><span class="cx"> invalid(&quot;'use strict'; function foo(...yield) { }&quot;);
</span><span class="cx"> invalid(&quot;function foo(...if) { }&quot;);
</span><span class="cx"> 
</span><ins>+debug(&quot;non-simple parameter list&quot;)
+invalid(&quot;function foo(...restParam) { 'use strict'; }&quot;);
+invalid(&quot;function foo(...restParam) { 'a'; 'use strict'; }&quot;);
+invalid(&quot;function foo({x}) { 'use strict'; }&quot;);
+invalid(&quot;function foo({x}) { 'a'; 'use strict'; }&quot;);
+invalid(&quot;function foo(a = 20) { 'use strict'; }&quot;);
+invalid(&quot;function foo(a = 20) { 'a'; 'use strict'; }&quot;);
+invalid(&quot;function foo({a} = 20) { 'use strict'; }&quot;);
+invalid(&quot;function foo({a} = 20) { 'a'; 'use strict'; }&quot;);
+invalid(&quot;function foo([a]) { 'use strict'; }&quot;);
+invalid(&quot;function foo([a]) { 'a'; 'use strict'; }&quot;);
+invalid(&quot;function foo(foo, bar, a = 25) { 'use strict'; }&quot;);
+invalid(&quot;function foo(foo, bar, a = 25) { 'a'; 'use strict'; }&quot;);
+invalid(&quot;function foo(foo, bar, baz, ...rest) { 'use strict'; }&quot;);
+invalid(&quot;function foo(foo, bar, baz, ...rest) { 'a'; 'use strict'; }&quot;);
+invalid(&quot;function foo(a = function() { }) { 'use strict'; a(); }&quot;);
+invalid(&quot;function foo(a = function() { }) { 'a'; 'use strict'; a(); }&quot;);
+invalid(&quot;let foo = (...restParam) =&gt; { 'use strict'; }&quot;);
+invalid(&quot;let foo = (...restParam) =&gt; { 'a'; 'use strict'; }&quot;);
+invalid(&quot;let foo = ({x}) =&gt; { 'use strict'; }&quot;);
+invalid(&quot;let foo = ({x}) =&gt; { 'a'; 'use strict'; }&quot;);
+invalid(&quot;let foo = (a = 20) =&gt; { 'use strict'; }&quot;);
+invalid(&quot;let foo = (a = 20) =&gt; { 'a'; 'use strict'; }&quot;);
+invalid(&quot;let foo = ({a} = 20) =&gt; { 'use strict'; }&quot;);
+invalid(&quot;let foo = ({a} = 20) =&gt; { 'a'; 'use strict'; }&quot;);
+invalid(&quot;let foo = ([a]) =&gt; { 'use strict'; }&quot;);
+invalid(&quot;let foo = ([a]) =&gt; { 'a'; 'use strict'; }&quot;);
+invalid(&quot;let foo = (foo, bar, a = 25) =&gt; { 'use strict'; }&quot;);
+invalid(&quot;let foo = (foo, bar, a = 25) =&gt; { 'a'; 'use strict'; }&quot;);
+invalid(&quot;let foo = (foo, bar, baz, ...rest) =&gt; { 'use strict'; }&quot;);
+invalid(&quot;let foo = (foo, bar, baz, ...rest) =&gt; { 'a'; 'use strict'; }&quot;);
+invalid(&quot;let foo = (a = function() { }) =&gt; { 'use strict'; a(); }&quot;);
+invalid(&quot;let foo = (a = function() { }) =&gt; { 'a'; 'use strict'; a(); }&quot;);
+valid(&quot;function outer() { 'use strict'; function foo(...restParam) {  } }&quot;);
+valid(&quot;function outer() { 'use strict'; function foo(a,b,c,...restParam) {  } }&quot;);
+valid(&quot;function outer() { 'use strict'; function foo(a = 20,b,c,...restParam) {  } }&quot;);
+valid(&quot;function outer() { 'use strict'; function foo(a = 20,{b},c,...restParam) {  } }&quot;);
+valid(&quot;function outer() { 'use strict'; function foo(a = 20,{b},[c] = 5,...restParam) {  } }&quot;);
+valid(&quot;function outer() { 'use strict'; function foo(a = 20) {  } }&quot;);
+valid(&quot;function outer() { 'use strict'; function foo(a,b,c,{d} = 20) {  } }&quot;);
+invalid(&quot;function outer() { 'use strict'; function foo(...restParam) { 'use strict';  } }&quot;);
+invalid(&quot;function outer() { 'use strict'; function foo(a,b,c,...restParam) {  'use strict'; } }&quot;);
+invalid(&quot;function outer() { 'use strict'; function foo(a = 20,b,c,...restParam) {  'use strict'; } }&quot;);
+invalid(&quot;function outer() { 'use strict'; function foo(a = 20,{b},c,...restParam) { 'use strict'; } }&quot;);
+invalid(&quot;function outer() { 'use strict'; function foo(a = 20,{b},[c] = 5,...restParam) { 'use strict'; } }&quot;);
+invalid(&quot;function outer() { 'use strict'; function foo(a = 20) {  'use strict';} }&quot;);
+invalid(&quot;function outer() { 'use strict'; function foo(a,b,c,{d} = 20) { 'use strict'; } }&quot;);
+
</ins><span class="cx"> debug(&quot;Arrow function&quot;);
</span><span class="cx"> valid(&quot;var x = (x) =&gt; x;&quot;);
</span><span class="cx"> valid(&quot;var x = (x, y, z) =&gt; x;&quot;);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (203262 => 203263)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-07-15 02:07:45 UTC (rev 203262)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-07-15 02:11:42 UTC (rev 203263)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2016-07-14  Saam Barati  &lt;sbarati@apple.com&gt;
+
+        It should be a syntax error to have a 'use strict' directive inside a function that has a non-simple parameter list
+        https://bugs.webkit.org/show_bug.cgi?id=159790
+        &lt;rdar://problem/27171636&gt;
+
+        Reviewed by Geoffrey Garen.
+
+        Is is a syntax error for a function's parameter list to be non-simple
+        and for the function to also contain a 'use strict' directive.
+
+        See section 14.2.1 of the spec:
+        https://tc39.github.io/ecma262/#sec-arrow-function-definitions-static-semantics-early-errors
+
+        * parser/Parser.cpp:
+        (JSC::Parser&lt;LexerType&gt;::parseSourceElements):
+        (JSC::Parser&lt;LexerType&gt;::parseFormalParameters):
+        * parser/Parser.h:
+        (JSC::Scope::Scope):
+        (JSC::Scope::strictMode):
+        (JSC::Scope::isValidStrictMode):
+        (JSC::Scope::shadowsArguments):
+        (JSC::Scope::setHasNonSimpleParameterList):
+        (JSC::Scope::hasNonSimpleParameterList):
+        (JSC::Scope::copyCapturedVariablesToVector):
+
</ins><span class="cx"> 2016-07-14  Geoffrey Garen  &lt;ggaren@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         ASSERTION FAILED: : this != replacement()
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Parser.cpp (203262 => 203263)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Parser.cpp        2016-07-15 02:07:45 UTC (rev 203262)
+++ trunk/Source/JavaScriptCore/parser/Parser.cpp        2016-07-15 02:11:42 UTC (rev 203263)
</span><span class="lines">@@ -420,6 +420,7 @@
</span><span class="cx">                             semanticFail(&quot;Cannot declare a variable named 'arguments' in strict mode&quot;);
</span><span class="cx">                         if (hasDeclaredVariable(m_vm-&gt;propertyNames-&gt;eval))
</span><span class="cx">                             semanticFail(&quot;Cannot declare a variable named 'eval' in strict mode&quot;);
</span><ins>+                        semanticFailIfTrue(currentScope()-&gt;hasNonSimpleParameterList(), &quot;'use strict' directive not allowed inside a function with a non-simple parameter list&quot;);
</ins><span class="cx">                         semanticFailIfFalse(isValidStrictMode(), &quot;Invalid parameters or function name in strict mode&quot;);
</span><span class="cx">                     }
</span><span class="cx">                     // Since strict mode is changed, restoring lexer state by calling next() may cause errors.
</span><span class="lines">@@ -1775,6 +1776,8 @@
</span><span class="cx">             defaultValue = parseDefaultValueForDestructuringPattern(context);
</span><span class="cx">         propagateError();
</span><span class="cx">         failIfDuplicateIfViolation();
</span><ins>+        if (isRestParameter || defaultValue || hasDestructuringPattern)
+            currentScope()-&gt;setHasNonSimpleParameterList();
</ins><span class="cx">         context.appendParameter(list, parameter, defaultValue);
</span><span class="cx">         if (!isRestParameter)
</span><span class="cx">             parameterCount++;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Parser.h (203262 => 203263)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Parser.h        2016-07-15 02:07:45 UTC (rev 203262)
+++ trunk/Source/JavaScriptCore/parser/Parser.h        2016-07-15 02:11:42 UTC (rev 203263)
</span><span class="lines">@@ -173,6 +173,7 @@
</span><span class="cx">         , m_isValidStrictMode(true)
</span><span class="cx">         , m_hasArguments(false)
</span><span class="cx">         , m_isEvalContext(false)
</span><ins>+        , m_hasNonSimpleParameterList(false)
</ins><span class="cx">         , m_evalContextType(EvalContextType::None)
</span><span class="cx">         , m_constructorKind(static_cast&lt;unsigned&gt;(ConstructorKind::None))
</span><span class="cx">         , m_expectedSuperBinding(static_cast&lt;unsigned&gt;(SuperBinding::NotNeeded))
</span><span class="lines">@@ -203,6 +204,7 @@
</span><span class="cx">         , m_isValidStrictMode(other.m_isValidStrictMode)
</span><span class="cx">         , m_hasArguments(other.m_hasArguments)
</span><span class="cx">         , m_isEvalContext(other.m_isEvalContext)
</span><ins>+        , m_hasNonSimpleParameterList(other.m_hasNonSimpleParameterList)
</ins><span class="cx">         , m_constructorKind(other.m_constructorKind)
</span><span class="cx">         , m_expectedSuperBinding(other.m_expectedSuperBinding)
</span><span class="cx">         , m_loopDepth(other.m_loopDepth)
</span><span class="lines">@@ -644,6 +646,12 @@
</span><span class="cx">     bool strictMode() const { return m_strictMode; }
</span><span class="cx">     bool isValidStrictMode() const { return m_isValidStrictMode; }
</span><span class="cx">     bool shadowsArguments() const { return m_shadowsArguments; }
</span><ins>+    void setHasNonSimpleParameterList()
+    {
+        m_isValidStrictMode = false;
+        m_hasNonSimpleParameterList = true;
+    }
+    bool hasNonSimpleParameterList() const { return m_hasNonSimpleParameterList; }
</ins><span class="cx"> 
</span><span class="cx">     void copyCapturedVariablesToVector(const UniquedStringImplPtrSet&amp; usedVariables, Vector&lt;UniquedStringImpl*, 8&gt;&amp; vector)
</span><span class="cx">     {
</span><span class="lines">@@ -747,6 +755,7 @@
</span><span class="cx">     bool m_isValidStrictMode;
</span><span class="cx">     bool m_hasArguments;
</span><span class="cx">     bool m_isEvalContext;
</span><ins>+    bool m_hasNonSimpleParameterList;
</ins><span class="cx">     EvalContextType m_evalContextType;
</span><span class="cx">     unsigned m_constructorKind;
</span><span class="cx">     unsigned m_expectedSuperBinding;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstresses6defaultparametersjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/stress/es6-default-parameters.js (203262 => 203263)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/es6-default-parameters.js        2016-07-15 02:07:45 UTC (rev 203262)
+++ trunk/Source/JavaScriptCore/tests/stress/es6-default-parameters.js        2016-07-15 02:11:42 UTC (rev 203263)
</span><span class="lines">@@ -79,7 +79,6 @@
</span><span class="cx"> shouldThrow(tricky);
</span><span class="cx"> 
</span><span class="cx"> function strict(x, y = x) {
</span><del>-    'use strict';
</del><span class="cx">     assert(x === y);
</span><span class="cx"> }
</span><span class="cx"> strict(20);
</span><span class="lines">@@ -146,24 +145,30 @@
</span><span class="cx"> }
</span><span class="cx"> augmentsArguments3();
</span><span class="cx"> 
</span><del>-function augmentsArguments4(x = 10) {
</del><ins>+function augmentsArguments4(x) {
</ins><span class="cx">     &quot;use strict&quot;;
</span><del>-    assert(x === 10);
</del><ins>+    function inner(x = 10) {
+        assert(x === 10);
</ins><span class="cx"> 
</span><del>-    assert(arguments[0] === undefined);
-    x = 20;
-    assert(arguments[0] === undefined);
</del><ins>+        assert(arguments[0] === undefined);
+        x = 20;
+        assert(arguments[0] === undefined);
+    }
+    inner(x);
</ins><span class="cx"> }
</span><span class="cx"> augmentsArguments4();
</span><span class="cx"> augmentsArguments4(undefined);
</span><span class="cx"> 
</span><del>-function augmentsArguments5(x = 10) {
</del><ins>+function augmentsArguments5(x) {
</ins><span class="cx">     &quot;use strict&quot;;
</span><del>-    assert(x === 20);
</del><ins>+    function inner(x = 10) {
+        assert(x === 20);
</ins><span class="cx"> 
</span><del>-    assert(arguments[0] === 20);
-    x = 20;
-    assert(arguments[0] === 20);
</del><ins>+        assert(arguments[0] === 20);
+        x = 20;
+        assert(arguments[0] === 20);
+    }
+    inner(x);
</ins><span class="cx"> }
</span><span class="cx"> augmentsArguments5(20);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressreflectsetjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/stress/reflect-set.js (203262 => 203263)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/reflect-set.js        2016-07-15 02:07:45 UTC (rev 203262)
+++ trunk/Source/JavaScriptCore/tests/stress/reflect-set.js        2016-07-15 02:11:42 UTC (rev 203263)
</span><span class="lines">@@ -571,126 +571,128 @@
</span><span class="cx">     [ Int32Array, 4 ],
</span><span class="cx">     [ Float32Array, 4 ],
</span><span class="cx">     [ Float64Array, 8 ],
</span><del>-].forEach(function typedArrayCase([ TypedArray, bytesPerElement ]) {
</del><ins>+].forEach((function() {
</ins><span class="cx">     'use strict';
</span><del>-    var object = new TypedArray(64);
-    shouldBe(Reflect.get(object, 'hello'), undefined);
-    shouldBe(Reflect.set(object, 'hello', 42), true);
-    shouldBe(Reflect.get(object, 'hello'), 42);
-    shouldBe(Reflect.get(object, 0), 0);
-    shouldBe(Reflect.set(object, 0, 42), true);
-    shouldBe(Reflect.get(object, 0), 42);
-    shouldBe(Reflect.get(object, symbol), undefined);
-    shouldBe(Reflect.set(object, symbol, 42), true);
-    shouldBe(Reflect.get(object, symbol), 42);
-    object[1000000] = 'Hello';
-    shouldBe(Reflect.set(object, 0, 50), true);
-    shouldBe(Reflect.get(object, 0), 50);
</del><ins>+    return function typedArrayCase([ TypedArray, bytesPerElement ]) {
+        var object = new TypedArray(64);
+        shouldBe(Reflect.get(object, 'hello'), undefined);
+        shouldBe(Reflect.set(object, 'hello', 42), true);
+        shouldBe(Reflect.get(object, 'hello'), 42);
+        shouldBe(Reflect.get(object, 0), 0);
+        shouldBe(Reflect.set(object, 0, 42), true);
+        shouldBe(Reflect.get(object, 0), 42);
+        shouldBe(Reflect.get(object, symbol), undefined);
+        shouldBe(Reflect.set(object, symbol, 42), true);
+        shouldBe(Reflect.get(object, symbol), 42);
+        object[1000000] = 'Hello';
+        shouldBe(Reflect.set(object, 0, 50), true);
+        shouldBe(Reflect.get(object, 0), 50);
</ins><span class="cx"> 
</span><del>-    var object = new TypedArray(64);
-    shouldBe(Reflect.defineProperty(object, 'hello', {
-        value: 'Cocoa',
-        writable: false
-    }), true);
-    shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
-    shouldBe(Reflect.set(object, 'hello', 42), false);
-    shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
-    shouldBe(Reflect.defineProperty(object, 0, {
-        value: 'Cocoa',
-        writable: false
-    }), false);
-    shouldBe(Reflect.get(object, 0), 0);
-    shouldBe(Reflect.set(object, 0, 42), true);
-    shouldBe(Reflect.get(object, 0), 42);
-    shouldBe(object.length, 64);
-    shouldBe(Reflect.defineProperty(object, symbol, {
-        value: 'Cocoa',
-        writable: false
-    }), true);
-    shouldBe(Reflect.get(object, symbol), 'Cocoa');
-    shouldBe(Reflect.set(object, symbol, 42), false);
-    shouldBe(Reflect.get(object, symbol), 'Cocoa');
</del><ins>+        var object = new TypedArray(64);
+        shouldBe(Reflect.defineProperty(object, 'hello', {
+            value: 'Cocoa',
+            writable: false
+        }), true);
+        shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
+        shouldBe(Reflect.set(object, 'hello', 42), false);
+        shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
+        shouldBe(Reflect.defineProperty(object, 0, {
+            value: 'Cocoa',
+            writable: false
+        }), false);
+        shouldBe(Reflect.get(object, 0), 0);
+        shouldBe(Reflect.set(object, 0, 42), true);
+        shouldBe(Reflect.get(object, 0), 42);
+        shouldBe(object.length, 64);
+        shouldBe(Reflect.defineProperty(object, symbol, {
+            value: 'Cocoa',
+            writable: false
+        }), true);
+        shouldBe(Reflect.get(object, symbol), 'Cocoa');
+        shouldBe(Reflect.set(object, symbol, 42), false);
+        shouldBe(Reflect.get(object, symbol), 'Cocoa');
</ins><span class="cx"> 
</span><del>-    var object = new TypedArray(64);
-    shouldBe(Reflect.get(object, 'byteLength'), bytesPerElement * 64);
-    shouldBe(Reflect.set(object, 'byteLength', 'Cappuccino'), false);
-    shouldBe(Reflect.get(object, 'byteLength'), bytesPerElement * 64);
</del><ins>+        var object = new TypedArray(64);
+        shouldBe(Reflect.get(object, 'byteLength'), bytesPerElement * 64);
+        shouldBe(Reflect.set(object, 'byteLength', 'Cappuccino'), false);
+        shouldBe(Reflect.get(object, 'byteLength'), bytesPerElement * 64);
</ins><span class="cx"> 
</span><del>-    var object = new TypedArray(64);
-    shouldBe(Reflect.get(object, 'byteLength'), bytesPerElement * 64);
-    shouldBe(Reflect.set(object, 'byteLength', 2000), false);
-    shouldBe(Reflect.get(object, 'byteLength'), bytesPerElement * 64);
</del><ins>+        var object = new TypedArray(64);
+        shouldBe(Reflect.get(object, 'byteLength'), bytesPerElement * 64);
+        shouldBe(Reflect.set(object, 'byteLength', 2000), false);
+        shouldBe(Reflect.get(object, 'byteLength'), bytesPerElement * 64);
</ins><span class="cx"> 
</span><del>-    var object = new TypedArray(64);
-    shouldBe(Reflect.defineProperty(object, 'hello', {
-        get() {
-            return 'Cocoa';
-        },
-        set() {
-        }
-    }), true);
-    shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
-    shouldBe(Reflect.set(object, 'hello', 42), true);  // Return true since the setter exists.
-    shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
-    shouldBe(Reflect.defineProperty(object, 0, {
-        get() {
-            return 'Cocoa';
-        },
-        set() {
-        }
-    }), false);
-    shouldBe(Reflect.get(object, 0), 0);
-    shouldBe(Reflect.set(object, 0, 42), true);  // Return true since the setter exists.
-    shouldBe(Reflect.get(object, 0), 42);
-    shouldBe(Reflect.defineProperty(object, symbol, {
-        get() {
-            return 'Cocoa';
-        },
-        set() {
-        }
-    }), true);
-    shouldBe(Reflect.get(object, symbol), 'Cocoa');
-    shouldBe(Reflect.set(object, symbol, 42), true);  // Return true since the setter exists.
-    shouldBe(Reflect.get(object, symbol), 'Cocoa');
</del><ins>+        var object = new TypedArray(64);
+        shouldBe(Reflect.defineProperty(object, 'hello', {
+            get() {
+                return 'Cocoa';
+            },
+            set() {
+            }
+        }), true);
+        shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
+        shouldBe(Reflect.set(object, 'hello', 42), true);  // Return true since the setter exists.
+        shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
+        shouldBe(Reflect.defineProperty(object, 0, {
+            get() {
+                return 'Cocoa';
+            },
+            set() {
+            }
+        }), false);
+        shouldBe(Reflect.get(object, 0), 0);
+        shouldBe(Reflect.set(object, 0, 42), true);  // Return true since the setter exists.
+        shouldBe(Reflect.get(object, 0), 42);
+        shouldBe(Reflect.defineProperty(object, symbol, {
+            get() {
+                return 'Cocoa';
+            },
+            set() {
+            }
+        }), true);
+        shouldBe(Reflect.get(object, symbol), 'Cocoa');
+        shouldBe(Reflect.set(object, symbol, 42), true);  // Return true since the setter exists.
+        shouldBe(Reflect.get(object, symbol), 'Cocoa');
</ins><span class="cx"> 
</span><del>-    var object = new TypedArray(64);
-    shouldBe(Reflect.defineProperty(object, 'hello', {
-        get() {
-            return 'Cocoa';
-        }
-    }), true);
-    shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
-    shouldBe(Reflect.set(object, 'hello', 42), false);
-    shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
-    shouldBe(Reflect.defineProperty(object, 0, {
-        get() {
-            return 'Cocoa';
-        }
-    }), false);
-    shouldBe(Reflect.get(object, 0), 0);
-    shouldBe(Reflect.set(object, 0, 42), true);
-    shouldBe(Reflect.get(object, 0), 42);
-    shouldBe(Reflect.defineProperty(object, symbol, {
-        get() {
-            return 'Cocoa';
-        }
-    }), true);
-    shouldBe(Reflect.get(object, symbol), 'Cocoa');
-    shouldBe(Reflect.set(object, symbol, 42), false);
-    shouldBe(Reflect.get(object, symbol), 'Cocoa');
</del><ins>+        var object = new TypedArray(64);
+        shouldBe(Reflect.defineProperty(object, 'hello', {
+            get() {
+                return 'Cocoa';
+            }
+        }), true);
+        shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
+        shouldBe(Reflect.set(object, 'hello', 42), false);
+        shouldBe(Reflect.get(object, 'hello'), 'Cocoa');
+        shouldBe(Reflect.defineProperty(object, 0, {
+            get() {
+                return 'Cocoa';
+            }
+        }), false);
+        shouldBe(Reflect.get(object, 0), 0);
+        shouldBe(Reflect.set(object, 0, 42), true);
+        shouldBe(Reflect.get(object, 0), 42);
+        shouldBe(Reflect.defineProperty(object, symbol, {
+            get() {
+                return 'Cocoa';
+            }
+        }), true);
+        shouldBe(Reflect.get(object, symbol), 'Cocoa');
+        shouldBe(Reflect.set(object, symbol, 42), false);
+        shouldBe(Reflect.get(object, symbol), 'Cocoa');
</ins><span class="cx"> 
</span><del>-    receiverTest(new TypedArray(64), new TypedArray(64));
-    receiverTest(new TypedArray(64), {});
-    receiverTest({}, new TypedArray(64));
</del><ins>+        receiverTest(new TypedArray(64), new TypedArray(64));
+        receiverTest(new TypedArray(64), {});
+        receiverTest({}, new TypedArray(64));
</ins><span class="cx"> 
</span><del>-    var object = new TypedArray(64);
-    var receiver = {};
-    // The receiver is ignored when the property name is an indexed one.
-    // shouldBe(Reflect.set(object, 0, 42, receiver), true);
-    shouldBe(Reflect.set(object, 0, 42, receiver), true);
-    shouldBe(Reflect.get(object, 0), 42);
-    shouldBe(receiver.hasOwnProperty(0), false);
-});
</del><ins>+        var object = new TypedArray(64);
+        var receiver = {};
+        // The receiver is ignored when the property name is an indexed one.
+        // shouldBe(Reflect.set(object, 0, 42, receiver), true);
+        shouldBe(Reflect.set(object, 0, 42, receiver), true);
+        shouldBe(Reflect.get(object, 0), 42);
+        shouldBe(receiver.hasOwnProperty(0), false);
+    };
+})());
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> (function argumentCase() {
</span></span></pre>
</div>
</div>

</body>
</html>