<!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>[213850] 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/213850">213850</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-03-13 10:03:19 -0700 (Mon, 13 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[JSC] It should be possible create a label named let when parsing Statement in non strict mode
https://bugs.webkit.org/show_bug.cgi?id=168684

Patch by Caio Lima &lt;ticaiolima@gmail.com&gt; on 2017-03-13
Reviewed by Saam Barati.

JSTests:

* ChakraCore/test/LetConst/DeclOutofBlock.baseline-jsc:

Source/JavaScriptCore:

This patch is fixing a Parser bug to allow define a label named
```let``` in sloppy mode when parsing a Statement.

* parser/Parser.cpp:
(JSC::Parser&lt;LexerType&gt;::parseStatement):

LayoutTests:

* js/let-syntax-expected.txt:
* js/script-tests/let-syntax.js:
(shouldNotHaveSyntaxErrorSloopyOnly):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJSTestsChakraCoretestLetConstDeclOutofBlockbaselinejsc">trunk/JSTests/ChakraCore/test/LetConst/DeclOutofBlock.baseline-jsc</a></li>
<li><a href="#trunkJSTestsChangeLog">trunk/JSTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsjsletsyntaxexpectedtxt">trunk/LayoutTests/js/let-syntax-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsletsyntaxjs">trunk/LayoutTests/js/script-tests/let-syntax.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>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJSTestsChakraCoretestLetConstDeclOutofBlockbaselinejsc"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/ChakraCore/test/LetConst/DeclOutofBlock.baseline-jsc (213849 => 213850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChakraCore/test/LetConst/DeclOutofBlock.baseline-jsc        2017-03-13 16:57:55 UTC (rev 213849)
+++ trunk/JSTests/ChakraCore/test/LetConst/DeclOutofBlock.baseline-jsc        2017-03-13 17:03:19 UTC (rev 213850)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><del>-SyntaxError: Unexpected identifier 'b'. Parse error.
</del><ins>+SyntaxError: Unexpected identifier 'b'
</ins><span class="cx"> SyntaxError: Unexpected keyword 'const'
</span><del>-SyntaxError: Unexpected identifier 'd'. Parse error.
-SyntaxError: Unexpected identifier 'd'. Parse error.
-SyntaxError: Unexpected identifier 'f'. Parse error.
</del><ins>+SyntaxError: Unexpected identifier 'd'
+SyntaxError: Unexpected identifier 'd'
+SyntaxError: Unexpected identifier 'f'
</ins><span class="cx"> success
</span></span></pre></div>
<a id="trunkJSTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/ChangeLog (213849 => 213850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChangeLog        2017-03-13 16:57:55 UTC (rev 213849)
+++ trunk/JSTests/ChangeLog        2017-03-13 17:03:19 UTC (rev 213850)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2017-03-13  Caio Lima  &lt;ticaiolima@gmail.com&gt;
+
+        [JSC] It should be possible create a label named let when parsing Statement in non strict mode
+        https://bugs.webkit.org/show_bug.cgi?id=168684
+
+        Reviewed by Saam Barati.
+
+        * ChakraCore/test/LetConst/DeclOutofBlock.baseline-jsc:
+
</ins><span class="cx"> 2017-03-10  Saam Barati  &lt;sbarati@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebAssembly: Make more demos run
</span></span></pre></div>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (213849 => 213850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-03-13 16:57:55 UTC (rev 213849)
+++ trunk/LayoutTests/ChangeLog        2017-03-13 17:03:19 UTC (rev 213850)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-03-13  Caio Lima  &lt;ticaiolima@gmail.com&gt;
+
+        [JSC] It should be possible create a label named let when parsing Statement in non strict mode
+        https://bugs.webkit.org/show_bug.cgi?id=168684
+
+        Reviewed by Saam Barati.
+
+        * js/let-syntax-expected.txt:
+        * js/script-tests/let-syntax.js:
+        (shouldNotHaveSyntaxErrorSloopyOnly):
+
</ins><span class="cx"> 2017-03-13  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Rebaseline js/dom/global-constructors-attributes.html.
</span></span></pre></div>
<a id="trunkLayoutTestsjsletsyntaxexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/let-syntax-expected.txt (213849 => 213850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/let-syntax-expected.txt        2017-03-13 16:57:55 UTC (rev 213849)
+++ trunk/LayoutTests/js/let-syntax-expected.txt        2017-03-13 17:03:19 UTC (rev 213850)
</span><span class="lines">@@ -69,6 +69,7 @@
</span><span class="cx"> PASS Does not have syntax error: ''use strict'; let x = { get foo() { let foo = 20; } };'
</span><span class="cx"> PASS Does not have syntax error: 'let x = { get foo() { class foo { } } };'
</span><span class="cx"> PASS Does not have syntax error: ''use strict'; let x = { get foo() { class foo { } } };'
</span><ins>+PASS Does not have syntax error: 'let x; with ({}) let: y = 3;'
</ins><span class="cx"> SyntaxError: Unexpected keyword 'let'. Can't use 'let' as an identifier name for a LexicalDeclaration.
</span><span class="cx"> SyntaxError: Unexpected keyword 'let'. Can't use 'let' as an identifier name for a LexicalDeclaration.
</span><span class="cx"> PASS Has syntax error: 'let let;'
</span><span class="lines">@@ -189,8 +190,8 @@
</span><span class="cx"> SyntaxError: Cannot declare a let variable twice: 'i'.
</span><span class="cx"> SyntaxError: Cannot declare a let variable twice: 'i'.
</span><span class="cx"> PASS Has syntax error: ''use strict'; for (let i = 20, j = 40, i = 10; i &lt; 10; i++) {}'
</span><del>-SyntaxError: Unexpected identifier 'x'. Parse error.
-SyntaxError: Unexpected identifier 'x'. Parse error.
</del><ins>+SyntaxError: Unexpected identifier 'x'
+SyntaxError: Unexpected identifier 'x'
</ins><span class="cx"> PASS Has syntax error: 'let x = 20; if (truth()) let x = 40;'
</span><span class="cx"> SyntaxError: Unexpected keyword 'let'
</span><span class="cx"> SyntaxError: Unexpected keyword 'let'
</span><span class="lines">@@ -387,6 +388,9 @@
</span><span class="cx"> SyntaxError: Cannot declare a class twice: 'x'.
</span><span class="cx"> SyntaxError: Cannot declare a class twice: 'x'.
</span><span class="cx"> PASS Has syntax error: ''use strict'; function f() { function x(){}; class x{}; }'
</span><ins>+SyntaxError: Unexpected identifier 'y'
+SyntaxError: Unexpected identifier 'y'
+PASS Has syntax error: 'let x; with ({}) let y = 3;'
</ins><span class="cx"> ReferenceError: Can't find variable: let
</span><span class="cx"> PASS Does not have syntax error: 'let;'
</span><span class="cx"> SyntaxError: Unexpected token ';'. Expected a parameter pattern or a ')' in parameter list.
</span><span class="lines">@@ -437,6 +441,10 @@
</span><span class="cx"> SyntaxError: Cannot use the keyword 'let' as a catch parameter name.
</span><span class="cx"> SyntaxError: Cannot use the keyword 'let' as a catch parameter name.
</span><span class="cx"> PASS Has syntax error: ''use strict'; try { } catch(let) {}'
</span><ins>+PASS Does not have syntax error: 'let x; if (true) let: x = 3;'
+SyntaxError: Unexpected keyword 'let'
+SyntaxError: Unexpected keyword 'let'
+PASS Has syntax error: ''use strict'; let x; if (true) let: x = 3;'
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsletsyntaxjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/script-tests/let-syntax.js (213849 => 213850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/let-syntax.js        2017-03-13 16:57:55 UTC (rev 213849)
+++ trunk/LayoutTests/js/script-tests/let-syntax.js        2017-03-13 17:03:19 UTC (rev 213850)
</span><span class="lines">@@ -31,6 +31,11 @@
</span><span class="cx">     testPassed(&quot;Has syntax error: '&quot; + str + &quot;'&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+function shouldHaveSyntaxErrorSloppyOnly(str) {
+    assert(hasSyntaxError(str));
+    assert(hasSyntaxError(&quot;function dummy() { &quot; + str + &quot; }&quot;));
+    testPassed(&quot;Has syntax error: '&quot; + str + &quot;'&quot;);
+}
</ins><span class="cx"> 
</span><span class="cx"> function shouldNotHaveSyntaxError(str) {
</span><span class="cx">     assert(!hasSyntaxError(str));
</span><span class="lines">@@ -53,6 +58,13 @@
</span><span class="cx">     testPassed(&quot;Has syntax error: '&quot; + str + &quot;'&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+function shouldNotHaveSyntaxErrorSloppyOnly(str)
+{
+    assert(!hasSyntaxError(str));
+    assert(!hasSyntaxError(&quot;(function dummy() { &quot; + str + &quot; })&quot;));
+    testPassed(&quot;Does not have syntax error: '&quot; + str + &quot;'&quot;);
+}
+
</ins><span class="cx"> shouldNotHaveSyntaxError(&quot;let x = 20; if (truth()) { let x = 30; }&quot;);
</span><span class="cx"> shouldNotHaveSyntaxError(&quot;let {x} = {x:20}; if (truth()) { let {x} = {x : 20}; }&quot;);
</span><span class="cx"> shouldNotHaveSyntaxError(&quot;let {x} = {x:20}; if (truth()) { let {y: x} = {y : 20}; }&quot;);
</span><span class="lines">@@ -86,6 +98,7 @@
</span><span class="cx"> shouldNotHaveSyntaxError(&quot;let x = { get foo() { const foo = 20; } };&quot;);
</span><span class="cx"> shouldNotHaveSyntaxError(&quot;let x = { get foo() { let foo = 20; } };&quot;);
</span><span class="cx"> shouldNotHaveSyntaxError(&quot;let x = { get foo() { class foo { } } };&quot;);
</span><ins>+shouldNotHaveSyntaxErrorSloppyOnly(&quot;let x; with ({}) let: y = 3;&quot;);
</ins><span class="cx"> 
</span><span class="cx"> shouldHaveSyntaxError(&quot;let let;&quot;);
</span><span class="cx"> shouldHaveSyntaxError(&quot;const let;&quot;);
</span><span class="lines">@@ -140,6 +153,7 @@
</span><span class="cx"> shouldHaveSyntaxError(&quot;function f() { class x{}; var [x] = 20; }&quot;);
</span><span class="cx"> shouldHaveSyntaxError(&quot;function f() { class x{};  function x(){} }&quot;);
</span><span class="cx"> shouldHaveSyntaxError(&quot;function f() { function x(){}; class x{}; }&quot;);
</span><ins>+shouldHaveSyntaxErrorSloppyOnly(&quot;let x; with ({}) let y = 3;&quot;);
</ins><span class="cx"> 
</span><span class="cx"> // Stay classy, ES6.
</span><span class="cx"> shouldHaveSyntaxErrorStrictOnly(&quot;let;&quot;);
</span><span class="lines">@@ -154,3 +168,4 @@
</span><span class="cx"> shouldHaveSyntaxErrorStrictOnly(&quot;let: for (v in {}) break;&quot;);
</span><span class="cx"> shouldHaveSyntaxErrorStrictOnly(&quot;let: for (var v = 0; false; ) {};&quot;);
</span><span class="cx"> shouldHaveSyntaxErrorStrictOnly(&quot;try { } catch(let) {}&quot;);
</span><ins>+shouldHaveSyntaxErrorStrictOnly(&quot;let x; if (true) let: x = 3;&quot;);
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (213849 => 213850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2017-03-13 16:57:55 UTC (rev 213849)
+++ trunk/Source/JavaScriptCore/ChangeLog        2017-03-13 17:03:19 UTC (rev 213850)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2017-03-13  Caio Lima  &lt;ticaiolima@gmail.com&gt;
+
+        [JSC] It should be possible create a label named let when parsing Statement in non strict mode
+        https://bugs.webkit.org/show_bug.cgi?id=168684
+
+        Reviewed by Saam Barati.
+
+        This patch is fixing a Parser bug to allow define a label named
+        ```let``` in sloppy mode when parsing a Statement.
+
+        * parser/Parser.cpp:
+        (JSC::Parser&lt;LexerType&gt;::parseStatement):
+
</ins><span class="cx"> 2017-03-11  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Structure::willStoreValueSlow needs to keep the property table alive until the end
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Parser.cpp (213849 => 213850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Parser.cpp        2017-03-13 16:57:55 UTC (rev 213849)
+++ trunk/Source/JavaScriptCore/parser/Parser.cpp        2017-03-13 17:03:19 UTC (rev 213850)
</span><span class="lines">@@ -1733,6 +1733,11 @@
</span><span class="cx">     case DEFAULT:
</span><span class="cx">         // These tokens imply the end of a set of source elements
</span><span class="cx">         return 0;
</span><ins>+    case LET: {
+        if (!strictMode())
+            goto identcase;
+        goto defaultCase;
+    }
</ins><span class="cx">     case ASYNC:
</span><span class="cx">         if (maybeParseAsyncFunctionDeclarationStatement(context, result, parentAllowsFunctionDeclarationAsStatement))
</span><span class="cx">             break;
</span><span class="lines">@@ -1740,6 +1745,7 @@
</span><span class="cx">     case IDENT:
</span><span class="cx">     case AWAIT:
</span><span class="cx">     case YIELD: {
</span><ins>+        identcase:
</ins><span class="cx">         bool allowFunctionDeclarationAsStatement = false;
</span><span class="cx">         result = parseExpressionOrLabelStatement(context, allowFunctionDeclarationAsStatement);
</span><span class="cx">         shouldSetPauseLocation = !context.shouldSkipPauseLocation(result);
</span><span class="lines">@@ -1752,6 +1758,7 @@
</span><span class="cx">         nonTrivialExpressionCount = m_parserState.nonTrivialExpressionCount;
</span><span class="cx">         FALLTHROUGH;
</span><span class="cx">     default:
</span><ins>+        defaultCase:
</ins><span class="cx">         TreeStatement exprStatement = parseExpressionStatement(context);
</span><span class="cx">         if (directive &amp;&amp; nonTrivialExpressionCount != m_parserState.nonTrivialExpressionCount)
</span><span class="cx">             directive = nullptr;
</span></span></pre>
</div>
</div>

</body>
</html>