From 58e9d8d871d0f047539870bd3eee2b860ad2ba82 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 28 Jun 2021 19:35:28 -0700 Subject: [PATCH] Normative: add `#x in obj` syntax (#2290) See https://github.com/tc39/proposal-private-fields-in-in/issues/7 --- spec.html | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spec.html b/spec.html index 80a449af80..9db84c545b 100644 --- a/spec.html +++ b/spec.html @@ -7708,6 +7708,7 @@

Static Semantics: IsFunctionDefinition

RelationalExpression `>=` ShiftExpression RelationalExpression `instanceof` ShiftExpression RelationalExpression `in` ShiftExpression + PrivateIdentifier `in` ShiftExpression EqualityExpression : EqualityExpression `==` RelationalExpression @@ -8456,6 +8457,7 @@

Static Semantics: AssignmentTargetType

RelationalExpression `>=` ShiftExpression RelationalExpression `instanceof` ShiftExpression RelationalExpression `in` ShiftExpression + PrivateIdentifier `in` ShiftExpression EqualityExpression : EqualityExpression `==` RelationalExpression @@ -17124,6 +17126,7 @@

Syntax

RelationalExpression[?In, ?Yield, ?Await] `>=` ShiftExpression[?Yield, ?Await] RelationalExpression[?In, ?Yield, ?Await] `instanceof` ShiftExpression[?Yield, ?Await] [+In] RelationalExpression[+In, ?Yield, ?Await] `in` ShiftExpression[?Yield, ?Await] + [+In] PrivateIdentifier `in` ShiftExpression[?Yield, ?Await]

The [In] grammar parameter is needed to avoid confusing the `in` operator in a relational expression with the `in` operator in a `for` statement.

@@ -17184,6 +17187,17 @@

Runtime Semantics: Evaluation

1. If Type(_rval_) is not Object, throw a *TypeError* exception. 1. Return ? HasProperty(_rval_, ? ToPropertyKey(_lval_)). + RelationalExpression : PrivateIdentifier `in` ShiftExpression + + 1. Let _privateIdentifier_ be the StringValue of |PrivateIdentifier|. + 1. Let _rref_ be the result of evaluating |ShiftExpression|. + 1. Let _rval_ be ? GetValue(_rref_). + 1. If Type(_rval_) is not Object, throw a *TypeError* exception. + 1. Let _privateEnv_ be the running execution context's PrivateEnvironment. + 1. Let _privateName_ be ! ResolvePrivateIdentifier(_privateEnv_, _privateIdentifier_). + 1. If ! PrivateElementFind(_privateName_, _rval_) is not ~empty~, return *true*. + 1. Return *false*. + @@ -21226,6 +21240,13 @@

Static Semantics: AllPrivateIdentifiersValid

1. Let _newNames_ be the list-concatenation of _names_ and PrivateBoundIdentifiers of |ClassBody|. 1. Return AllPrivateIdentifiersValid of |ClassElementList| with argument _newNames_. + + RelationalExpression : PrivateIdentifier `in` ShiftExpression + + 1. If _names_ contains the StringValue of |PrivateIdentifier|, then + 1. Return AllPrivateIdentifiersValid of |ShiftExpression| with argument _names_. + 1. Return *false*. +
@@ -22088,6 +22109,7 @@

Expression Rules

RelationalExpression `>=` ShiftExpression RelationalExpression `instanceof` ShiftExpression RelationalExpression `in` ShiftExpression + PrivateIdentifier `in` ShiftExpression ShiftExpression : ShiftExpression `<<` AdditiveExpression