Skip to content

Commit 8e5d501

Browse files
authored
Merge pull request #14 from rbuckton/disallow-using-in-switch-case
Disallow using/await using in a switch case/default clause
2 parents b6cebe4 + 98102fb commit 8e5d501

File tree

1 file changed

+12
-30
lines changed

1 file changed

+12
-30
lines changed

spec.html

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21729,7 +21729,10 @@ <h1>Static Semantics: Early Errors</h1>
2172921729
It is a Syntax Error if the BoundNames of |BindingList| contains any duplicate entries.
2173021730
</li>
2173121731
<li>
21732-
It is a Syntax Error if the goal symbol is |Script| and |UsingDeclaration| is not contained, either directly or indirectly, within a |Block|, |CaseBlock|, |ForStatement|, |ForInOfStatement|, |FunctionBody|, |GeneratorBody|, |AsyncGeneratorBody|, |AsyncFunctionBody|, or |ClassStaticBlockBody|.
21732+
It is a Syntax Error if the goal symbol is |Script| and |UsingDeclaration| is not contained, either directly or indirectly, within a |Block|, |ForStatement|, |ForInOfStatement|, |FunctionBody|, |GeneratorBody|, |AsyncGeneratorBody|, |AsyncFunctionBody|, or |ClassStaticBlockBody|.
21733+
</li>
21734+
<li>
21735+
It is a Syntax Error if |UsingDeclaration| is contained directly within the |StatementList| of either a |CaseClause| or |DefaultClause|.
2173321736
</li>
2173421737
</ul>
2173521738
<emu-grammar>
@@ -21745,7 +21748,10 @@ <h1>Static Semantics: Early Errors</h1>
2174521748
It is a Syntax Error if the BoundNames of |BindingList| contains any duplicate entries.
2174621749
</li>
2174721750
<li>
21748-
It is a Syntax Error if the goal symbol is |Script| and |AwaitUsingDeclaration| is not contained, either directly or indirectly, within a |Block|, |CaseBlock|, |ForStatement|, |ForInOfStatement|, |FunctionBody|, |GeneratorBody|, |AsyncGeneratorBody|, |AsyncFunctionBody|, or |ClassStaticBlockBody|.
21751+
It is a Syntax Error if the goal symbol is |Script| and |AwaitUsingDeclaration| is not contained, either directly or indirectly, within a |Block|, |ForStatement|, |ForInOfStatement|, |FunctionBody|, |GeneratorBody|, |AsyncGeneratorBody|, |AsyncFunctionBody|, or |ClassStaticBlockBody|.
21752+
</li>
21753+
<li>
21754+
It is a Syntax Error if |AwaitUsingDeclaration| is contained directly within the |StatementList| of either a |CaseClause| or |DefaultClause|.
2174921755
</li>
2175021756
</ul>
2175121757
<emu-grammar>LexicalBinding : BindingIdentifier Initializer?</emu-grammar>
@@ -25946,7 +25952,7 @@ <h1>
2594625952
<p>A potential tail position call that is immediately followed by return GetValue of the call result is also a possible tail position call. A function call cannot return a Reference Record, so such a GetValue operation will always return the same value as the actual function call result.</p>
2594725953
</emu-note>
2594825954
<emu-note>
25949-
<p>A `using` declaration or `await using` declaration that precedes a call in the same |Block|, |CaseBlock|, |ForStatement|, |ForInOfStatement|, |FunctionBody|, |GeneratorBody|, |AsyncGeneratorBody|, |AsyncFunctionBody|, or |ClassStaticBlockBody| prevents that call from being a possible tail position call.</p>
25955+
<p>A `using` declaration or `await using` declaration that precedes a call in the same |Block|, |ForStatement|, |ForInOfStatement|, |FunctionBody|, |GeneratorBody|, |AsyncGeneratorBody|, |AsyncFunctionBody|, or |ClassStaticBlockBody| prevents that call from being a possible tail position call.</p>
2595025956
</emu-note>
2595125957

2595225958
<emu-grammar>StatementList : StatementList StatementListItem</emu-grammar>
@@ -26042,21 +26048,17 @@ <h1>
2604226048
<emu-grammar>CaseBlock : `{` CaseClauses? DefaultClause CaseClauses? `}`</emu-grammar>
2604326049
<emu-alg>
2604426050
1. Let _has_ be *false*.
26045-
1. If the first |CaseClauses| is present, then
26046-
1. Set _has_ to HasCallInTailPosition of the first |CaseClauses| with argument _call_.
26047-
1. If _has_ is *true*, return *true*.
26048-
1. If HasUnterminatedUsingDeclaration of the first |CaseClauses| is *true*, return *false*.
26051+
1. If the first |CaseClauses| is present, then, set _has_ to HasCallInTailPosition of the first |CaseClauses| with argument _call_.
26052+
1. If _has_ is *true*, return *true*.
2604926053
1. Set _has_ to HasCallInTailPosition of |DefaultClause| with argument _call_.
2605026054
1. If _has_ is *true*, return *true*.
26051-
1. If HasUnterminatedUsingDeclaration of |DefaultClause| is *true*, return *false*.
2605226055
1. If the second |CaseClauses| is present, set _has_ to HasCallInTailPosition of the second |CaseClauses| with argument _call_.
2605326056
1. Return _has_.
2605426057
</emu-alg>
2605526058
<emu-grammar>CaseClauses : CaseClauses CaseClause</emu-grammar>
2605626059
<emu-alg>
2605726060
1. Let _has_ be HasCallInTailPosition of |CaseClauses| with argument _call_.
2605826061
1. If _has_ is *true*, return *true*.
26059-
1. If HasUnterminatedUsingDeclaration of |CaseClauses| is *true*, return *false*.
2606026062
1. Return HasCallInTailPosition of |CaseClause| with argument _call_.
2606126063
</emu-alg>
2606226064
<emu-grammar>
@@ -26292,9 +26294,6 @@ <h1>Static Semantics: HasUnterminatedUsingDeclaration ( ): a Boolean</h1>
2629226294
StatementListItem :
2629326295
Statement
2629426296

26295-
CaseBlock :
26296-
`{` `}`
26297-
2629826297
Declaration :
2629926298
HoistableDeclaration
2630026299
ClassDeclaration
@@ -26316,24 +26315,6 @@ <h1>Static Semantics: HasUnterminatedUsingDeclaration ( ): a Boolean</h1>
2631626315
<emu-alg>
2631726316
1. Return *true*.
2631826317
</emu-alg>
26319-
26320-
<emu-grammar>CaseClauses : CaseClauses CaseClause</emu-grammar>
26321-
<emu-alg>
26322-
1. Let _has_ be HasUnterminatedUsingDeclaration of |CaseClauses|.
26323-
1. If _has_ is *true*, return *true*.
26324-
1. Return HasUnterminatedUsingDeclaration of |CaseClause|.
26325-
</emu-alg>
26326-
26327-
<emu-grammar>
26328-
CaseClause :
26329-
`case` Expression `:` StatementList?
26330-
26331-
DefaultClause :
26332-
`default` `:` StatementList?
26333-
</emu-grammar>
26334-
<emu-alg>
26335-
1. If |StatementList| is present, return HasUnterminatedUsingDeclaration of |StatementList|.
26336-
</emu-alg>
2633726318
</emu-clause>
2633826319

2633926320
<emu-clause id="sec-preparefortailcall" type="abstract operation">
@@ -47024,6 +47005,7 @@ <h1>DisposableStack.prototype.adopt ( _value_, _onDispose_ )</h1>
4702447005
1. Return _value_.
4702547006
</emu-alg>
4702647007
</emu-clause>
47008+
4702747009
<emu-clause id="sec-disposablestack.prototype.constructor">
4702847010
<h1>DisposableStack.prototype.constructor</h1>
4702947011
<p>The initial value of `DisposableStack.prototype.constructor` is %DisposableStack%.</p>

0 commit comments

Comments
 (0)