blob: 12805771e991d3c997eb77f16206e1347709b95f [file] [log] [blame]
// This file was procedurally generated from the following sources:
// - src/class-elements/grammar-private-field-optional-chaining.case
// - src/class-elements/default/cls-expr.template
/*---
description: PrivateName after '?.' is valid syntax (field definitions in a class expression)
esid: prod-FieldDefinition
features: [class-fields-private, optional-chaining, class]
flags: [generated]
info: |
Updated Productions
OptionalChain[Yield, Await]:
`?.` `[` Expression[+In, ?Yield, ?Await] `]`
`?.` IdentifierName
`?.` Arguments[?Yield, ?Await]
`?.` TemplateLiteral[?Yield, ?Await, +Tagged]
`?.` PrivateIdentifier
---*/
var C = class {
#m = 'test262';
static access(obj) {
return obj?.#m;
}
}
let c = new C();
assert.sameValue(C.access(c), 'test262');
assert.sameValue(C.access(null), undefined);
assert.sameValue(C.access(undefined), undefined);
assert.throws(TypeError, function() {
C.access({});
}, 'accessed private field from an ordinary object');