8.4 Contains
8.4.1 Static Semantics: Contains
With parameter symbol.
Every grammar production alternative in this specification which is not listed below implicitly has the following default definition of Contains:
- For each child node child of this
Parse Node , do- If child is an instance of symbol, return
true . - If child is an instance of a nonterminal, then
- Let contained be the result of child
Contains symbol. - If contained is
true , returntrue .
- Let contained be the result of child
- If child is an instance of symbol, return
- Return
false .
- Return
false .
Static semantic rules that depend upon substructure generally do not look into function definitions.
- If symbol is
ClassBody , returntrue . - If symbol is
ClassHeritage , then- If
ClassHeritage is present, returntrue ; otherwise returnfalse .
- If
- Let inHeritage be
ClassHeritage Contains symbol. - If inHeritage is
true , returntrue . - Return the result of
ComputedPropertyContains forClassBody with argument symbol.
Static semantic rules that depend upon substructure generally do not look into class bodies except for
- If symbol is not one of
NewTarget ,SuperProperty ,SuperCall ,super
orthis
, returnfalse . - If
ArrowParameters Contains symbol istrue , returntrue . - Return
ConciseBody Contains symbol.
- Let formals be
CoveredFormalsList ofCoverParenthesizedExpressionAndArrowParameterList . - Return formals
Contains symbol.
- If symbol is not one of
NewTarget ,SuperProperty ,SuperCall ,super
, orthis
, returnfalse . - Return
AsyncConciseBody Contains symbol.
- If symbol is not one of
NewTarget ,SuperProperty ,SuperCall ,super
, orthis
, returnfalse . - Let head be
CoveredAsyncArrowHead ofCoverCallExpressionAndAsyncArrowHead . - If head
Contains symbol istrue , returntrue . - Return
AsyncConciseBody Contains symbol.
Contains is used to detect new.target
, this
, and super
usage within an
- If symbol is
MethodDefinition , returntrue . - Return the result of
ComputedPropertyContains forMethodDefinition with argument symbol.
- Return
false .
- If
MemberExpression Contains symbol istrue , returntrue . - Return
false .
- If symbol is the
ReservedWord super
, returntrue . - Return
false .
- If
CallExpression Contains symbol istrue , returntrue . - Return
false .
- Return
false .
- If
OptionalChain Contains symbol istrue , returntrue . - Return
false .
8.4.2 Static Semantics: ComputedPropertyContains
With parameter symbol.
- Return
false .
- Return the result of
ComputedPropertyName Contains symbol.
- Return the result of
ComputedPropertyContains forPropertyName with argument symbol.
- Return the result of
ComputedPropertyContains forPropertyName with argument symbol.
- Return the result of
ComputedPropertyContains forPropertyName with argument symbol.
- Let inList be
ComputedPropertyContains ofClassElementList with argument symbol. - If inList is
true , returntrue . - Return the result of
ComputedPropertyContains forClassElement with argument symbol.
- Return
false .
- Return the result of
ComputedPropertyContains forPropertyName with argument symbol.