From e3c5cd5c4288c44fa589dc0a86b06a702ae7ce8d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 27 Jan 2021 14:15:07 -0800 Subject: [PATCH] Normative: add `#x in obj` syntax (#2290) See https://github.com/tc39/proposal-private-fields-in-in/issues/7 --- spec.html | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/spec.html b/spec.html index e025b1d477c..d6ee2d1e1e1 100644 --- a/spec.html +++ b/spec.html @@ -7898,6 +7898,7 @@

Static Semantics: IsFunctionDefinition

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

Static Semantics: AssignmentTargetType

RelationalExpression `>=` ShiftExpression RelationalExpression `instanceof` ShiftExpression RelationalExpression `in` ShiftExpression + PrivateIdentifier `in` ShiftExpression EqualityExpression : EqualityExpression `==` RelationalExpression @@ -17210,6 +17212,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.

@@ -17274,6 +17277,23 @@

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 _env_ be the running execution context's PrivateEnvironment. + 1. Let _privateNameBinding_ be ? ResolveBinding(_privateIdentifier_, _env_). + 1. Let _privateName_ be ? GetValue(_privateNameBinding_). + 1. Assert: _privateName_ is a Private Name. + 1. If _privateName_.[[Kind]] is *"field"*, then + 1. If ! PrivateFieldFind(_privateName_, _rval_) is not ~empty~, return *true*. + 1. Else, + 1. Assert: _privateName_.[[Kind]] is *"method"* or *"accessor"*. + 1. If PrivateBrandCheck(_rval_, _privateName_) is not an abrupt completion, return *true*. + 1. Return *false*. + @@ -21234,6 +21254,12 @@

Static Semantics: AllPrivateIdentifiersValid

1. Return AllPrivateIdentifiersValid of |ClassElementList| with argument _newNames_. + RelationalExpression : PrivateIdentifier `in` ShiftExpression + + 1. If StringValue of |PrivateIdentifier| is in _names_, return *true*. + 1. Return *false*. + +

For all other grammatical productions, recurse on subexpressions/substatements, passing in the _names_ of the caller. If all pieces return *true*, then return *true*. If any returns *false*, return *false*.

@@ -22078,6 +22104,7 @@

Expression Rules

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