Skip to content

Commit fb00f69

Browse files
anbaljharb
authored andcommitted
Call SetFunctionName as part of ClassDefinitionEvaluation
1 parent f2f01d2 commit fb00f69

File tree

1 file changed

+12
-27
lines changed

1 file changed

+12
-27
lines changed

spec.html

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19790,14 +19790,14 @@ <h1>Static Semantics: PropName</h1>
1979019790

1979119791
<emu-clause id="sec-runtime-semantics-classdefinitionevaluation">
1979219792
<h1>Runtime Semantics: ClassDefinitionEvaluation</h1>
19793-
<p>With parameter _className_.</p>
19793+
<p>With parameters _classBinding_ and _className_.</p>
1979419794
<emu-grammar>ClassTail : ClassHeritage? `{` ClassBody? `}`</emu-grammar>
1979519795
<emu-alg>
1979619796
1. Let _lex_ be the LexicalEnvironment of the running execution context.
1979719797
1. Let _classScope_ be NewDeclarativeEnvironment(_lex_).
1979819798
1. Let _classScopeEnvRec_ be _classScope_'s EnvironmentRecord.
19799-
1. If _className_ is not *undefined*, then
19800-
1. Perform _classScopeEnvRec_.CreateImmutableBinding(_className_, *true*).
19799+
1. If _classBinding_ is not *undefined*, then
19800+
1. Perform _classScopeEnvRec_.CreateImmutableBinding(_classBinding_, *true*).
1980119801
1. If |ClassHeritage_opt| is not present, then
1980219802
1. Let _protoParent_ be the intrinsic object %ObjectPrototype%.
1980319803
1. Let _constructorParent_ be the intrinsic object %FunctionPrototype%.
@@ -19833,6 +19833,8 @@ <h1>Runtime Semantics: ClassDefinitionEvaluation</h1>
1983319833
1. If |ClassHeritage_opt| is present, set _F_.[[ConstructorKind]] to `"derived"`.
1983419834
1. Perform MakeConstructor(_F_, *false*, _proto_).
1983519835
1. Perform MakeClassConstructor(_F_).
19836+
1. If _className_ is not *undefined*, then
19837+
1. Perform SetFunctionName(_F_, _className_).
1983619838
1. Perform CreateMethodProperty(_proto_, `"constructor"`, _F_).
1983719839
1. If |ClassBody_opt| is not present, let _methods_ be a new empty List.
1983819840
1. Else, let _methods_ be NonConstructorMethodDefinitions of |ClassBody|.
@@ -19845,8 +19847,8 @@ <h1>Runtime Semantics: ClassDefinitionEvaluation</h1>
1984519847
1. Set the running execution context's LexicalEnvironment to _lex_.
1984619848
1. Return Completion(_status_).
1984719849
1. Set the running execution context's LexicalEnvironment to _lex_.
19848-
1. If _className_ is not *undefined*, then
19849-
1. Perform _classScopeEnvRec_.InitializeBinding(_className_, _F_).
19850+
1. If _classBinding_ is not *undefined*, then
19851+
1. Perform _classScopeEnvRec_.InitializeBinding(_classBinding_, _F_).
1985019852
1. Return _F_.
1985119853
</emu-alg>
1985219854
</emu-clause>
@@ -19856,20 +19858,18 @@ <h1>Runtime Semantics: BindingClassDeclarationEvaluation</h1>
1985619858
<emu-grammar>ClassDeclaration : `class` BindingIdentifier ClassTail</emu-grammar>
1985719859
<emu-alg>
1985819860
1. Let _className_ be StringValue of |BindingIdentifier|.
19859-
1. Let _value_ be the result of ClassDefinitionEvaluation of |ClassTail| with argument _className_.
19861+
1. Let _value_ be the result of ClassDefinitionEvaluation of |ClassTail| with arguments _className_ and _className_.
1986019862
1. ReturnIfAbrupt(_value_).
19861-
1. Let _hasNameProperty_ be ? HasOwnProperty(_value_, `"name"`).
19862-
1. If _hasNameProperty_ is *false*, perform SetFunctionName(_value_, _className_).
1986319863
1. Let _env_ be the running execution context's LexicalEnvironment.
1986419864
1. Perform ? InitializeBoundName(_className_, _value_, _env_).
1986519865
1. Return _value_.
1986619866
</emu-alg>
1986719867
<emu-grammar>ClassDeclaration : `class` ClassTail</emu-grammar>
1986819868
<emu-alg>
19869-
1. Return the result of ClassDefinitionEvaluation of |ClassTail| with argument *undefined*.
19869+
1. Return the result of ClassDefinitionEvaluation of |ClassTail| with arguments *undefined* and `"default"`.
1987019870
</emu-alg>
1987119871
<emu-note>
19872-
<p><emu-grammar>ClassDeclaration : `class` ClassTail</emu-grammar> only occurs as part of an |ExportDeclaration| and the setting of a name property and establishing its binding are handled as part of the evaluation action for that production. See <emu-xref href="#sec-exports-runtime-semantics-evaluation"></emu-xref>.</p>
19872+
<p><emu-grammar>ClassDeclaration : `class` ClassTail</emu-grammar> only occurs as part of an |ExportDeclaration| and establishing its binding is handled as part of the evaluation action for that production. See <emu-xref href="#sec-exports-runtime-semantics-evaluation"></emu-xref>.</p>
1987319873
</emu-note>
1987419874
</emu-clause>
1987519875

@@ -19878,11 +19878,7 @@ <h1>Runtime Semantics: NamedEvaluation</h1>
1987819878
<p>With parameter _name_.</p>
1987919879
<emu-grammar>ClassExpression : `class` ClassTail</emu-grammar>
1988019880
<emu-alg>
19881-
1. Let _value_ be the result of evaluating this |ClassExpression|.
19882-
1. Let _hasNameProperty_ be ? HasOwnProperty(_value_, `"name"`).
19883-
1. If _hasNameProperty_ is *false*, then
19884-
1. Perform SetFunctionName(_value_, _name_).
19885-
1. Return _value_.
19881+
1. Return the result of ClassDefinitionEvaluation of |ClassTail| with arguments *undefined* and _name_.
1988619882
</emu-alg>
1988719883
</emu-clause>
1988819884

@@ -19900,17 +19896,8 @@ <h1>Runtime Semantics: Evaluation</h1>
1990019896
<emu-alg>
1990119897
1. If |BindingIdentifier_opt| is not present, let _className_ be *undefined*.
1990219898
1. Else, let _className_ be StringValue of |BindingIdentifier|.
19903-
1. Let _value_ be the result of ClassDefinitionEvaluation of |ClassTail| with argument _className_.
19904-
1. ReturnIfAbrupt(_value_).
19905-
1. If _className_ is not *undefined*, then
19906-
1. Let _hasNameProperty_ be ? HasOwnProperty(_value_, `"name"`).
19907-
1. If _hasNameProperty_ is *false*, then
19908-
1. Perform SetFunctionName(_value_, _className_).
19909-
1. Return NormalCompletion(_value_).
19899+
1. Return the result of ClassDefinitionEvaluation of |ClassTail| with arguments _className_ and _className_.
1991019900
</emu-alg>
19911-
<emu-note>
19912-
<p>If the class definition included a `name` static method then that method is not over-written with a `name` data property for the class name.</p>
19913-
</emu-note>
1991419901
</emu-clause>
1991519902
</emu-clause>
1991619903

@@ -23121,8 +23108,6 @@ <h1>Runtime Semantics: Evaluation</h1>
2312123108
1. ReturnIfAbrupt(_value_).
2312223109
1. Let _className_ be the sole element of BoundNames of |ClassDeclaration|.
2312323110
1. If _className_ is `"*default*"`, then
23124-
1. Let _hasNameProperty_ be ? HasOwnProperty(_value_, `"name"`).
23125-
1. If _hasNameProperty_ is *false*, perform SetFunctionName(_value_, `"default"`).
2312623111
1. Let _env_ be the running execution context's LexicalEnvironment.
2312723112
1. Perform ? InitializeBoundName(`"*default*"`, _value_, _env_).
2312823113
1. Return NormalCompletion(~empty~).

0 commit comments

Comments
 (0)