← Back to Pull requests

Editorial: Simplify TV and TRV #4084

Open
gibson042 opened this pull request with 309 lines diff across 1 files
View on GitHub
gibson042 gibson042 commented on Nov 16, 2026 20:18 UTC
Author

Extends #4082

Merge TV and TRV into a single parameterized TV
Remove deep traversal by leveraging CodePointsToString

Diff: 309 lines (+119 / -190) across 1 files Reviewer: nicolo-ribaudo Review duration: 26657m
All Vouch review confidence checks passed
Residual risk 0.05 = Change Risk (0.37) × (1 − Review Confidence (0.87)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 309 lines diff across 1 files
0.37
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.84 · 5 substantive comment(s)
0.84
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
87%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.343
Real PR Conversation Timeline
12 items
github-actions[bot] github-actions[bot] commented on Nov 16, 2026 20:23 UTC
Bot

The rendered spec preview for this PR is available as a single page at https://tc39.es/ecma262/pr/4084 and as multiple pages at https://tc39.es/ecma262/pr/4084/multipage .

<hidden purpose="for-rewritable-pr-comment-action-use" value="tc39_pr_preview_comment"></hidden>

nicolo-ribaudo nicolo-ribaudo commented on code on Nov 17, 2026 11:41 UTC
Code Review
spec.html:1
@@ -17893,164 +17893,108 @@ <h2>Syntax</h2>
         <p>|TemplateSubstitutionTail| is used by the |InputElementTemplateTail| alternative lexical goal.</p>
       </emu-note>
 
-      <emu-clause id="sec-static-semantics-tv" type="sdo" oldids="sec-static-semantics-tv-and-trv">
-        <h1>Static Semantics: TV ( ): a String or *undefined*</h1>
+      <emu-clause id="sec-static-semantics-tv" type="sdo" oldids="sec-static-semantics-tv-and-trv,sec-static-semantics-trv">
+        <h1>
+          Static Semantics: TV (
+            _escapes_: ~raw~ or ~cooked~,
+          ): a String or *undefined*
+        </h1>
         <dl class="header">
           <dt>description</dt>
-          <dd>A template literal component is interpreted by TV as a value of the String type. TV is used to construct the indexed components of a template object (colloquially, the template values). In TV, escape sequences are replaced by the UTF-16 code unit(s) of the Unicode code point represented by the escape sequence.</dd>
+          <dd>A template literal component is interpreted by TV as a String. TV is used to construct the indexed and raw components of a template object (colloquially, the respective “template values” and “template raw values”). _escapes_ controls whether backslash sequences are retained or interpreted.</dd>
         </dl>
-        <ul>
-          <li>
-            The TV of <emu-grammar>NoSubstitutionTemplate :: ``` ```</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateHead :: ``` `${`</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateMiddle :: `}` `${`</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateTail :: `}` ```</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacters :: TemplateCharacter TemplateCharacters</emu-grammar> is *undefined* if the TV of |TemplateCharacter| is *undefined* or the TV of |TemplateCharacters| is *undefined*. Otherwise, it is the string-concatenation of the TV of |TemplateCharacter| and the TV of |TemplateCharacters|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: SourceCharacter but not one of ``` or `\` or `$` or LineTerminator</emu-grammar> is the result of performing UTF16EncodeCodePoint on the code point matched by |SourceCharacter|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `$`</emu-grammar> is the String value consisting of the code unit 0x0024 (DOLLAR SIGN).
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `\` TemplateEscapeSequence</emu-grammar> is the SV of |TemplateEscapeSequence|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `\` NotEscapeSequence</emu-grammar> is *undefined*.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: LineTerminatorSequence</emu-grammar> is the TRV of |LineTerminatorSequence|.
-          </li>
-          <li>
-            The TV of <emu-grammar>LineContinuation :: `\` LineTerminatorSequence</emu-grammar> is the empty String.
-          </li>
-        </ul>
-      </emu-clause>
+        <emu-grammar>
+          NoSubstitutionTemplate ::
+            ``` ```
+
+          TemplateHead ::
+            ``` `${`
+
+          TemplateMiddle ::
+            `}` `${`
+
+          TemplateTail ::
+            `}` ```
+        </emu-grammar>
+        <emu-alg>
+          1. Return the empty String.
+        </emu-alg>
+
+        <emu-grammar>
+          TemplateCharacters :: TemplateCharacter TemplateCharacters
+        </emu-grammar>
+        <emu-alg>
+          1. Let _tv1_ be the TV of |TemplateCharacter| with argument _escapes_.
+          1. Let _tv2_ be the TV of |TemplateCharacters| with argument _escapes_.
+          1. If _escapes_ is ~cooked~ and (_tv1_ is *undefined* or _tv2_ is *undefined*), then
+            1. Return *undefined*.
+          1. Assert: _tv1_ and _tv2_ are both Strings.
+          1. Return the string-concatenation of _tv1_ and _tv2_.
+        </emu-alg>
+
+        <emu-grammar>
+          TemplateCharacter ::
+            `$` [lookahead != `{`]
+            SourceCharacter but not one of ``` or `\` or `$` or LineTerminator
+        </emu-grammar>
+        <emu-alg>
+          1. Return the result of performing UTF16EncodeCodePoint on the single code point matched by |TemplateCharacter|.
+        </emu-alg>
+
+        <emu-grammar>
+          LineTerminatorSequence ::
+            &lt;LF&gt;
+            &lt;CR&gt;
+            &lt;CR&gt; &lt;LF&gt;
+        </emu-grammar>
+        <emu-alg>
+          1. Return the String value consisting of the code unit 0x000A (LINE FEED).
+        </emu-alg>
+        <emu-note>
+          <p>An explicit |TemplateEscapeSequence| is needed to include a &lt;CR> or &lt;CR>&lt;LF> sequence.</p>
+        </emu-note>
+
+        <emu-grammar>
+          LineTerminatorSequence ::
+            &lt;LS&gt;
+            &lt;PS&gt;
+        </emu-grammar>
+        <emu-alg>
+          1. Return the result of performing UTF16EncodeCodePoint on the single code point matched by |LineTerminatorSequence|.

UTF16EncodeCodePoint is just an AO, can we call it as such?

          1. Return UTF16EncodeCodePoint(the single code point matched by |LineTerminatorSequence|).

nicolo-ribaudo nicolo-ribaudo commented on code on Nov 17, 2026 11:42 UTC
Code Review
spec.html:1
@@ -17893,164 +17893,108 @@ <h2>Syntax</h2>
         <p>|TemplateSubstitutionTail| is used by the |InputElementTemplateTail| alternative lexical goal.</p>
       </emu-note>
 
-      <emu-clause id="sec-static-semantics-tv" type="sdo" oldids="sec-static-semantics-tv-and-trv">
-        <h1>Static Semantics: TV ( ): a String or *undefined*</h1>
+      <emu-clause id="sec-static-semantics-tv" type="sdo" oldids="sec-static-semantics-tv-and-trv,sec-static-semantics-trv">
+        <h1>
+          Static Semantics: TV (
+            _escapes_: ~raw~ or ~cooked~,
+          ): a String or *undefined*
+        </h1>
         <dl class="header">
           <dt>description</dt>
-          <dd>A template literal component is interpreted by TV as a value of the String type. TV is used to construct the indexed components of a template object (colloquially, the template values). In TV, escape sequences are replaced by the UTF-16 code unit(s) of the Unicode code point represented by the escape sequence.</dd>
+          <dd>A template literal component is interpreted by TV as a String. TV is used to construct the indexed and raw components of a template object (colloquially, the respective “template values” and “template raw values”). _escapes_ controls whether backslash sequences are retained or interpreted.</dd>
         </dl>
-        <ul>
-          <li>
-            The TV of <emu-grammar>NoSubstitutionTemplate :: ``` ```</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateHead :: ``` `${`</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateMiddle :: `}` `${`</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateTail :: `}` ```</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacters :: TemplateCharacter TemplateCharacters</emu-grammar> is *undefined* if the TV of |TemplateCharacter| is *undefined* or the TV of |TemplateCharacters| is *undefined*. Otherwise, it is the string-concatenation of the TV of |TemplateCharacter| and the TV of |TemplateCharacters|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: SourceCharacter but not one of ``` or `\` or `$` or LineTerminator</emu-grammar> is the result of performing UTF16EncodeCodePoint on the code point matched by |SourceCharacter|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `$`</emu-grammar> is the String value consisting of the code unit 0x0024 (DOLLAR SIGN).
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `\` TemplateEscapeSequence</emu-grammar> is the SV of |TemplateEscapeSequence|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `\` NotEscapeSequence</emu-grammar> is *undefined*.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: LineTerminatorSequence</emu-grammar> is the TRV of |LineTerminatorSequence|.
-          </li>
-          <li>
-            The TV of <emu-grammar>LineContinuation :: `\` LineTerminatorSequence</emu-grammar> is the empty String.
-          </li>
-        </ul>
-      </emu-clause>
+        <emu-grammar>
+          NoSubstitutionTemplate ::
+            ``` ```
+
+          TemplateHead ::
+            ``` `${`
+
+          TemplateMiddle ::
+            `}` `${`
+
+          TemplateTail ::
+            `}` ```
+        </emu-grammar>
+        <emu-alg>
+          1. Return the empty String.
+        </emu-alg>
+
+        <emu-grammar>
+          TemplateCharacters :: TemplateCharacter TemplateCharacters
+        </emu-grammar>
+        <emu-alg>
+          1. Let _tv1_ be the TV of |TemplateCharacter| with argument _escapes_.
+          1. Let _tv2_ be the TV of |TemplateCharacters| with argument _escapes_.
+          1. If _escapes_ is ~cooked~ and (_tv1_ is *undefined* or _tv2_ is *undefined*), then
+            1. Return *undefined*.
+          1. Assert: _tv1_ and _tv2_ are both Strings.
+          1. Return the string-concatenation of _tv1_ and _tv2_.
+        </emu-alg>
+
+        <emu-grammar>
+          TemplateCharacter ::
+            `$` [lookahead != `{`]
+            SourceCharacter but not one of ``` or `\` or `$` or LineTerminator
+        </emu-grammar>
+        <emu-alg>
+          1. Return the result of performing UTF16EncodeCodePoint on the single code point matched by |TemplateCharacter|.

          1. Return UTF16EncodeCodePoint(the single code point matched by |TemplateCharacter|).

nicolo-ribaudo nicolo-ribaudo commented on code on Nov 17, 2026 11:47 UTC
Code Review
spec.html:1
@@ -19092,11 +19036,10 @@ <h1>
         <dl class="header">
         </dl>
         <emu-alg>
-          1. If _escapes_ is ~raw~, return the TRV of _templateToken_.
-          1. Return the TV of _templateToken_.
+          1. Return the TV of _templateToken_ with argument _escapes_.
         </emu-alg>

This AO is not just an alias for TV, can we remove it? (or rename TV to TemplateString)

nicolo-ribaudo nicolo-ribaudo commented on code on Nov 17, 2026 11:54 UTC
Code Review
spec.html:1
@@ -17893,164 +17893,108 @@ <h2>Syntax</h2>
         <p>|TemplateSubstitutionTail| is used by the |InputElementTemplateTail| alternative lexical goal.</p>
       </emu-note>
 
-      <emu-clause id="sec-static-semantics-tv" type="sdo" oldids="sec-static-semantics-tv-and-trv">
-        <h1>Static Semantics: TV ( ): a String or *undefined*</h1>
+      <emu-clause id="sec-static-semantics-tv" type="sdo" oldids="sec-static-semantics-tv-and-trv,sec-static-semantics-trv">
+        <h1>
+          Static Semantics: TV (
+            _escapes_: ~raw~ or ~cooked~,
+          ): a String or *undefined*
+        </h1>
         <dl class="header">
           <dt>description</dt>
-          <dd>A template literal component is interpreted by TV as a value of the String type. TV is used to construct the indexed components of a template object (colloquially, the template values). In TV, escape sequences are replaced by the UTF-16 code unit(s) of the Unicode code point represented by the escape sequence.</dd>
+          <dd>A template literal component is interpreted by TV as a String. TV is used to construct the indexed and raw components of a template object (colloquially, the respective “template values” and “template raw values”). _escapes_ controls whether backslash sequences are retained or interpreted.</dd>
         </dl>
-        <ul>
-          <li>
-            The TV of <emu-grammar>NoSubstitutionTemplate :: ``` ```</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateHead :: ``` `${`</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateMiddle :: `}` `${`</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateTail :: `}` ```</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacters :: TemplateCharacter TemplateCharacters</emu-grammar> is *undefined* if the TV of |TemplateCharacter| is *undefined* or the TV of |TemplateCharacters| is *undefined*. Otherwise, it is the string-concatenation of the TV of |TemplateCharacter| and the TV of |TemplateCharacters|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: SourceCharacter but not one of ``` or `\` or `$` or LineTerminator</emu-grammar> is the result of performing UTF16EncodeCodePoint on the code point matched by |SourceCharacter|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `$`</emu-grammar> is the String value consisting of the code unit 0x0024 (DOLLAR SIGN).
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `\` TemplateEscapeSequence</emu-grammar> is the SV of |TemplateEscapeSequence|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `\` NotEscapeSequence</emu-grammar> is *undefined*.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: LineTerminatorSequence</emu-grammar> is the TRV of |LineTerminatorSequence|.
-          </li>
-          <li>
-            The TV of <emu-grammar>LineContinuation :: `\` LineTerminatorSequence</emu-grammar> is the empty String.
-          </li>
-        </ul>
-      </emu-clause>
+        <emu-grammar>
+          NoSubstitutionTemplate ::
+            ``` ```
+
+          TemplateHead ::
+            ``` `${`
+
+          TemplateMiddle ::
+            `}` `${`
+
+          TemplateTail ::
+            `}` ```
+        </emu-grammar>
+        <emu-alg>
+          1. Return the empty String.
+        </emu-alg>
+
+        <emu-grammar>
+          TemplateCharacters :: TemplateCharacter TemplateCharacters
+        </emu-grammar>
+        <emu-alg>
+          1. Let _tv1_ be the TV of |TemplateCharacter| with argument _escapes_.
+          1. Let _tv2_ be the TV of |TemplateCharacters| with argument _escapes_.
+          1. If _escapes_ is ~cooked~ and (_tv1_ is *undefined* or _tv2_ is *undefined*), then
+            1. Return *undefined*.

tv1/tv2 being undefined already imply that _escapes_ is cooked, so this should be enough:

          1. If _tv1_ is *undefined* or _tv2_ is *undefined*, return *undefined*.

nicolo-ribaudo nicolo-ribaudo commented on code on Nov 17, 2026 11:55 UTC
Code Review
spec.html:1
@@ -17893,164 +17893,108 @@ <h2>Syntax</h2>
         <p>|TemplateSubstitutionTail| is used by the |InputElementTemplateTail| alternative lexical goal.</p>
       </emu-note>
 
-      <emu-clause id="sec-static-semantics-tv" type="sdo" oldids="sec-static-semantics-tv-and-trv">
-        <h1>Static Semantics: TV ( ): a String or *undefined*</h1>
+      <emu-clause id="sec-static-semantics-tv" type="sdo" oldids="sec-static-semantics-tv-and-trv,sec-static-semantics-trv">
+        <h1>
+          Static Semantics: TV (
+            _escapes_: ~raw~ or ~cooked~,
+          ): a String or *undefined*
+        </h1>
         <dl class="header">
           <dt>description</dt>
-          <dd>A template literal component is interpreted by TV as a value of the String type. TV is used to construct the indexed components of a template object (colloquially, the template values). In TV, escape sequences are replaced by the UTF-16 code unit(s) of the Unicode code point represented by the escape sequence.</dd>
+          <dd>A template literal component is interpreted by TV as a String. TV is used to construct the indexed and raw components of a template object (colloquially, the respective “template values” and “template raw values”). _escapes_ controls whether backslash sequences are retained or interpreted.</dd>
         </dl>
-        <ul>
-          <li>
-            The TV of <emu-grammar>NoSubstitutionTemplate :: ``` ```</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateHead :: ``` `${`</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateMiddle :: `}` `${`</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateTail :: `}` ```</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacters :: TemplateCharacter TemplateCharacters</emu-grammar> is *undefined* if the TV of |TemplateCharacter| is *undefined* or the TV of |TemplateCharacters| is *undefined*. Otherwise, it is the string-concatenation of the TV of |TemplateCharacter| and the TV of |TemplateCharacters|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: SourceCharacter but not one of ``` or `\` or `$` or LineTerminator</emu-grammar> is the result of performing UTF16EncodeCodePoint on the code point matched by |SourceCharacter|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `$`</emu-grammar> is the String value consisting of the code unit 0x0024 (DOLLAR SIGN).
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `\` TemplateEscapeSequence</emu-grammar> is the SV of |TemplateEscapeSequence|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `\` NotEscapeSequence</emu-grammar> is *undefined*.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: LineTerminatorSequence</emu-grammar> is the TRV of |LineTerminatorSequence|.
-          </li>
-          <li>
-            The TV of <emu-grammar>LineContinuation :: `\` LineTerminatorSequence</emu-grammar> is the empty String.
-          </li>
-        </ul>
-      </emu-clause>
+        <emu-grammar>
+          NoSubstitutionTemplate ::
+            ``` ```
+
+          TemplateHead ::
+            ``` `${`
+
+          TemplateMiddle ::
+            `}` `${`
+
+          TemplateTail ::
+            `}` ```
+        </emu-grammar>
+        <emu-alg>
+          1. Return the empty String.
+        </emu-alg>
+
+        <emu-grammar>
+          TemplateCharacters :: TemplateCharacter TemplateCharacters
+        </emu-grammar>
+        <emu-alg>
+          1. Let _tv1_ be the TV of |TemplateCharacter| with argument _escapes_.
+          1. Let _tv2_ be the TV of |TemplateCharacters| with argument _escapes_.
+          1. If _escapes_ is ~cooked~ and (_tv1_ is *undefined* or _tv2_ is *undefined*), then
+            1. Return *undefined*.

Or

          1. If _tv1_ is *undefined* or _tv2_ is *undefined*, then
            1. Assert: _escapes_ is ~cooked~.
            1. Return *undefined*.

nicolo-ribaudo nicolo-ribaudo commented on code on Nov 17, 2026 11:57 UTC
Code Review
spec.html:1
@@ -17893,164 +17893,108 @@ <h2>Syntax</h2>
         <p>|TemplateSubstitutionTail| is used by the |InputElementTemplateTail| alternative lexical goal.</p>
       </emu-note>
 
-      <emu-clause id="sec-static-semantics-tv" type="sdo" oldids="sec-static-semantics-tv-and-trv">
-        <h1>Static Semantics: TV ( ): a String or *undefined*</h1>
+      <emu-clause id="sec-static-semantics-tv" type="sdo" oldids="sec-static-semantics-tv-and-trv,sec-static-semantics-trv">
+        <h1>
+          Static Semantics: TV (
+            _escapes_: ~raw~ or ~cooked~,
+          ): a String or *undefined*
+        </h1>
         <dl class="header">
           <dt>description</dt>
-          <dd>A template literal component is interpreted by TV as a value of the String type. TV is used to construct the indexed components of a template object (colloquially, the template values). In TV, escape sequences are replaced by the UTF-16 code unit(s) of the Unicode code point represented by the escape sequence.</dd>
+          <dd>A template literal component is interpreted by TV as a String. TV is used to construct the indexed and raw components of a template object (colloquially, the respective “template values” and “template raw values”). _escapes_ controls whether backslash sequences are retained or interpreted.</dd>
         </dl>
-        <ul>
-          <li>
-            The TV of <emu-grammar>NoSubstitutionTemplate :: ``` ```</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateHead :: ``` `${`</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateMiddle :: `}` `${`</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateTail :: `}` ```</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacters :: TemplateCharacter TemplateCharacters</emu-grammar> is *undefined* if the TV of |TemplateCharacter| is *undefined* or the TV of |TemplateCharacters| is *undefined*. Otherwise, it is the string-concatenation of the TV of |TemplateCharacter| and the TV of |TemplateCharacters|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: SourceCharacter but not one of ``` or `\` or `$` or LineTerminator</emu-grammar> is the result of performing UTF16EncodeCodePoint on the code point matched by |SourceCharacter|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `$`</emu-grammar> is the String value consisting of the code unit 0x0024 (DOLLAR SIGN).
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `\` TemplateEscapeSequence</emu-grammar> is the SV of |TemplateEscapeSequence|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `\` NotEscapeSequence</emu-grammar> is *undefined*.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: LineTerminatorSequence</emu-grammar> is the TRV of |LineTerminatorSequence|.
-          </li>
-          <li>
-            The TV of <emu-grammar>LineContinuation :: `\` LineTerminatorSequence</emu-grammar> is the empty String.
-          </li>
-        </ul>
-      </emu-clause>
+        <emu-grammar>
+          NoSubstitutionTemplate ::
+            ``` ```
+
+          TemplateHead ::
+            ``` `${`
+
+          TemplateMiddle ::
+            `}` `${`
+
+          TemplateTail ::
+            `}` ```
+        </emu-grammar>
+        <emu-alg>
+          1. Return the empty String.
+        </emu-alg>
+
+        <emu-grammar>
+          TemplateCharacters :: TemplateCharacter TemplateCharacters
+        </emu-grammar>
+        <emu-alg>
+          1. Let _tv1_ be the TV of |TemplateCharacter| with argument _escapes_.
+          1. Let _tv2_ be the TV of |TemplateCharacters| with argument _escapes_.
+          1. If _escapes_ is ~cooked~ and (_tv1_ is *undefined* or _tv2_ is *undefined*), then
+            1. Return *undefined*.
+          1. Assert: _tv1_ and _tv2_ are both Strings.
+          1. Return the string-concatenation of _tv1_ and _tv2_.
+        </emu-alg>
+
+        <emu-grammar>
+          TemplateCharacter ::
+            `$` [lookahead != `{`]

I don't think we need the lookahead restriction here in the SDO, since the SDOs apply on an already parsed tree

gibson042 gibson042 commented on code on Nov 17, 2026 19:12 UTC
Code Review
spec.html:1
@@ -17893,164 +17893,108 @@ <h2>Syntax</h2>
         <p>|TemplateSubstitutionTail| is used by the |InputElementTemplateTail| alternative lexical goal.</p>
       </emu-note>
 
-      <emu-clause id="sec-static-semantics-tv" type="sdo" oldids="sec-static-semantics-tv-and-trv">
-        <h1>Static Semantics: TV ( ): a String or *undefined*</h1>
+      <emu-clause id="sec-static-semantics-tv" type="sdo" oldids="sec-static-semantics-tv-and-trv,sec-static-semantics-trv">
+        <h1>
+          Static Semantics: TV (
+            _escapes_: ~raw~ or ~cooked~,
+          ): a String or *undefined*
+        </h1>
         <dl class="header">
           <dt>description</dt>
-          <dd>A template literal component is interpreted by TV as a value of the String type. TV is used to construct the indexed components of a template object (colloquially, the template values). In TV, escape sequences are replaced by the UTF-16 code unit(s) of the Unicode code point represented by the escape sequence.</dd>
+          <dd>A template literal component is interpreted by TV as a String. TV is used to construct the indexed and raw components of a template object (colloquially, the respective “template values” and “template raw values”). _escapes_ controls whether backslash sequences are retained or interpreted.</dd>
         </dl>
-        <ul>
-          <li>
-            The TV of <emu-grammar>NoSubstitutionTemplate :: ``` ```</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateHead :: ``` `${`</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateMiddle :: `}` `${`</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateTail :: `}` ```</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacters :: TemplateCharacter TemplateCharacters</emu-grammar> is *undefined* if the TV of |TemplateCharacter| is *undefined* or the TV of |TemplateCharacters| is *undefined*. Otherwise, it is the string-concatenation of the TV of |TemplateCharacter| and the TV of |TemplateCharacters|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: SourceCharacter but not one of ``` or `\` or `$` or LineTerminator</emu-grammar> is the result of performing UTF16EncodeCodePoint on the code point matched by |SourceCharacter|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `$`</emu-grammar> is the String value consisting of the code unit 0x0024 (DOLLAR SIGN).
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `\` TemplateEscapeSequence</emu-grammar> is the SV of |TemplateEscapeSequence|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `\` NotEscapeSequence</emu-grammar> is *undefined*.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: LineTerminatorSequence</emu-grammar> is the TRV of |LineTerminatorSequence|.
-          </li>
-          <li>
-            The TV of <emu-grammar>LineContinuation :: `\` LineTerminatorSequence</emu-grammar> is the empty String.
-          </li>
-        </ul>
-      </emu-clause>
+        <emu-grammar>
+          NoSubstitutionTemplate ::
+            ``` ```
+
+          TemplateHead ::
+            ``` `${`
+
+          TemplateMiddle ::
+            `}` `${`
+
+          TemplateTail ::
+            `}` ```
+        </emu-grammar>
+        <emu-alg>
+          1. Return the empty String.
+        </emu-alg>
+
+        <emu-grammar>
+          TemplateCharacters :: TemplateCharacter TemplateCharacters
+        </emu-grammar>
+        <emu-alg>
+          1. Let _tv1_ be the TV of |TemplateCharacter| with argument _escapes_.
+          1. Let _tv2_ be the TV of |TemplateCharacters| with argument _escapes_.
+          1. If _escapes_ is ~cooked~ and (_tv1_ is *undefined* or _tv2_ is *undefined*), then
+            1. Return *undefined*.
+          1. Assert: _tv1_ and _tv2_ are both Strings.
+          1. Return the string-concatenation of _tv1_ and _tv2_.
+        </emu-alg>
+
+        <emu-grammar>
+          TemplateCharacter ::
+            `$` [lookahead != `{`]
+            SourceCharacter but not one of ``` or `\` or `$` or LineTerminator
+        </emu-grammar>
+        <emu-alg>
+          1. Return the result of performing UTF16EncodeCodePoint on the single code point matched by |TemplateCharacter|.
+        </emu-alg>
+
+        <emu-grammar>
+          LineTerminatorSequence ::
+            &lt;LF&gt;
+            &lt;CR&gt;
+            &lt;CR&gt; &lt;LF&gt;
+        </emu-grammar>
+        <emu-alg>
+          1. Return the String value consisting of the code unit 0x000A (LINE FEED).
+        </emu-alg>
+        <emu-note>
+          <p>An explicit |TemplateEscapeSequence| is needed to include a &lt;CR> or &lt;CR>&lt;LF> sequence.</p>
+        </emu-note>
+
+        <emu-grammar>
+          LineTerminatorSequence ::
+            &lt;LS&gt;
+            &lt;PS&gt;
+        </emu-grammar>
+        <emu-alg>
+          1. Return the result of performing UTF16EncodeCodePoint on the single code point matched by |LineTerminatorSequence|.

Yes, but upon further reflection I actually think CodePointsToString would be even better. Updated.

gibson042 gibson042 commented on code on Nov 17, 2026 19:12 UTC
Code Review
spec.html:1
@@ -19092,11 +19036,10 @@ <h1>
         <dl class="header">
         </dl>
         <emu-alg>
-          1. If _escapes_ is ~raw~, return the TRV of _templateToken_.
-          1. Return the TV of _templateToken_.
+          1. Return the TV of _templateToken_ with argument _escapes_.
         </emu-alg>

Done.

gibson042 gibson042 commented on code on Nov 17, 2026 19:12 UTC
Code Review
spec.html:1
@@ -17893,164 +17893,108 @@ <h2>Syntax</h2>
         <p>|TemplateSubstitutionTail| is used by the |InputElementTemplateTail| alternative lexical goal.</p>
       </emu-note>
 
-      <emu-clause id="sec-static-semantics-tv" type="sdo" oldids="sec-static-semantics-tv-and-trv">
-        <h1>Static Semantics: TV ( ): a String or *undefined*</h1>
+      <emu-clause id="sec-static-semantics-tv" type="sdo" oldids="sec-static-semantics-tv-and-trv,sec-static-semantics-trv">
+        <h1>
+          Static Semantics: TV (
+            _escapes_: ~raw~ or ~cooked~,
+          ): a String or *undefined*
+        </h1>
         <dl class="header">
           <dt>description</dt>
-          <dd>A template literal component is interpreted by TV as a value of the String type. TV is used to construct the indexed components of a template object (colloquially, the template values). In TV, escape sequences are replaced by the UTF-16 code unit(s) of the Unicode code point represented by the escape sequence.</dd>
+          <dd>A template literal component is interpreted by TV as a String. TV is used to construct the indexed and raw components of a template object (colloquially, the respective “template values” and “template raw values”). _escapes_ controls whether backslash sequences are retained or interpreted.</dd>
         </dl>
-        <ul>
-          <li>
-            The TV of <emu-grammar>NoSubstitutionTemplate :: ``` ```</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateHead :: ``` `${`</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateMiddle :: `}` `${`</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateTail :: `}` ```</emu-grammar> is the empty String.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacters :: TemplateCharacter TemplateCharacters</emu-grammar> is *undefined* if the TV of |TemplateCharacter| is *undefined* or the TV of |TemplateCharacters| is *undefined*. Otherwise, it is the string-concatenation of the TV of |TemplateCharacter| and the TV of |TemplateCharacters|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: SourceCharacter but not one of ``` or `\` or `$` or LineTerminator</emu-grammar> is the result of performing UTF16EncodeCodePoint on the code point matched by |SourceCharacter|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `$`</emu-grammar> is the String value consisting of the code unit 0x0024 (DOLLAR SIGN).
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `\` TemplateEscapeSequence</emu-grammar> is the SV of |TemplateEscapeSequence|.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: `\` NotEscapeSequence</emu-grammar> is *undefined*.
-          </li>
-          <li>
-            The TV of <emu-grammar>TemplateCharacter :: LineTerminatorSequence</emu-grammar> is the TRV of |LineTerminatorSequence|.
-          </li>
-          <li>
-            The TV of <emu-grammar>LineContinuation :: `\` LineTerminatorSequence</emu-grammar> is the empty String.
-          </li>
-        </ul>
-      </emu-clause>
+        <emu-grammar>
+          NoSubstitutionTemplate ::
+            ``` ```
+
+          TemplateHead ::
+            ``` `${`
+
+          TemplateMiddle ::
+            `}` `${`
+
+          TemplateTail ::
+            `}` ```
+        </emu-grammar>
+        <emu-alg>
+          1. Return the empty String.
+        </emu-alg>
+
+        <emu-grammar>
+          TemplateCharacters :: TemplateCharacter TemplateCharacters
+        </emu-grammar>
+        <emu-alg>
+          1. Let _tv1_ be the TV of |TemplateCharacter| with argument _escapes_.
+          1. Let _tv2_ be the TV of |TemplateCharacters| with argument _escapes_.
+          1. If _escapes_ is ~cooked~ and (_tv1_ is *undefined* or _tv2_ is *undefined*), then
+            1. Return *undefined*.
+          1. Assert: _tv1_ and _tv2_ are both Strings.
+          1. Return the string-concatenation of _tv1_ and _tv2_.
+        </emu-alg>
+
+        <emu-grammar>
+          TemplateCharacter ::
+            `$` [lookahead != `{`]

You're right, but they are valid AFAIK—and are potentially clarifying in this context (see also IsCharacterClass and CharacterValue).

nicolo-ribaudo nicolo-ribaudo approved these changes on Nov 18, 2026 23:06 UTC
Approved Reviewer

Approved these changes.

Assignees
gibson042 gibson042
Labels
risk: low confidence: 87.4% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 37.3% (MEDIUM) · Higher = larger blast radius
37.3%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 87.4% · Lower = rushed or shallow review
87.4%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 4.7% · Safe to merge
4.7%
Repository