Skip to content
This repository was archived by the owner on Jan 25, 2022. It is now read-only.

Commit c11f737

Browse files
committed
Prevent ASI from messing with forbidden template literals
Fixes #56
1 parent 5994d2c commit c11f737

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

spec.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
<link href="ecmarkup.css" rel="stylesheet">
55
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
66
<script src="ecmarkup.js"></script>
7+
<style>
8+
ins .hljs.hljs {
9+
background-color: inherit;
10+
}
11+
</style>
712
<script>
813
if (location.hostname.endsWith('.github.io') && location.protocol !== 'https:') {
914
location.protocol = 'https:';
@@ -146,9 +151,11 @@ <h2>Syntax</h2>
146151
OptionalChainingPunctuator `[` Expression[+In, ?Yield, ?Await] `]`
147152
OptionalChainingPunctuator IdentifierName
148153
OptionalChainingPunctuator Arguments[?Yield, ?Await]
154+
OptionalChainingPunctuator TemplateLiteral[?Yield, ?Await, +Tagged]
149155
OptionalChain[?Yield, ?Await] `[` Expression[+In, ?Yield, ?Await] `]`
150156
OptionalChain[?Yield, ?Await] `.` IdentifierName
151157
OptionalChain[?Yield, ?Await] Arguments[?Yield, ?Await]
158+
OptionalChain[?Yield, ?Await] TemplateLiteral[?Yield, ?Await, +Tagged]
152159
</ins>
153160

154161
LeftHandSideExpression[Yield, Await] :
@@ -166,6 +173,35 @@ <h2>Supplemental Syntax</h2>
166173
<emu-clause id="sec-static-semantics">
167174
<h1>Static Semantics (<a href="https://tc39.github.io/ecma262/#sec-static-semantics">12.3.1</a>)</h1>
168175

176+
<ins class="block">
177+
<emu-clause id="sec-left-hand-side-expressions-static-semantics-early-errors">
178+
<h1>Static Semantics: Early Errors</h1>
179+
<emu-grammar>
180+
OptionalChain[Yield, Await] :
181+
OptionalChainingPunctuator TemplateLiteral[?Yield, ?Await, +Tagged]
182+
OptionalChain[?Yield, ?Await] TemplateLiteral[?Yield, ?Await, +Tagged]
183+
</emu-grammar>
184+
<ul>
185+
<li>
186+
It is a Syntax Error if any code matches this production.
187+
</li>
188+
</ul>
189+
<emu-note>
190+
<p>This production exists in order to prevent automatic semicolon insertion rules (<emu-xref href="#sec-automatic-semicolon-insertion"></emu-xref>) to be applied to the following code:</p>
191+
<pre><code class="javascript">
192+
a?.b
193+
`c`
194+
</code></pre>
195+
<p>so that it would be interpreted as two valid statements. The purpose is to maintain consistency with similar code without optional chaining operator:</p>
196+
<pre><code class="javascript">
197+
a.b
198+
`c`
199+
</code></pre>
200+
<p>which is a valid statement and where automatic semicolon insertion does not apply.</p>
201+
</emu-note>
202+
</emu-clause>
203+
</ins>
204+
169205
<emu-clause id="sec-left-hand-side-expressions-static-semantics-coveredcallexpression">
170206
<h1>Static Semantics: CoveredCallExpression</h1>
171207
<emu-grammar>

0 commit comments

Comments
 (0)