Bug 1625116 - add templateStringListExpr to list of optionalexprs; r=jorendorff
authoryulia <ystartsev@mozilla.com>
Thu, 02 Apr 2020 20:08:15 +0000
changeset 521996 d06d14647f6fe993990383a12b185a3a54bf4872
parent 521995 976858118c046b6b2bf26031f99393bcb98900ea
child 521997 4456cc2e6533b22f41b67c162d71c9e2147d3929
push id37281
push userbtara@mozilla.com
push dateSat, 04 Apr 2020 09:29:13 +0000
treeherdermozilla-central@26bcd52f3e76 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1625116
milestone76.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1625116 - add templateStringListExpr to list of optionalexprs; r=jorendorff Differential Revision: https://phabricator.services.mozilla.com/D69078
js/src/frontend/BytecodeEmitter.cpp
js/src/tests/non262/expressions/optional-chain.js
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -7717,16 +7717,17 @@ bool BytecodeEmitter::emitOptionalTree(
           kind == ParseNodeKind::NumberExpr ||
           kind == ParseNodeKind::BigIntExpr ||
           kind == ParseNodeKind::StringExpr ||
           kind == ParseNodeKind::ArrayExpr ||
           kind == ParseNodeKind::ObjectExpr ||
           kind == ParseNodeKind::Function || kind == ParseNodeKind::ClassDecl ||
           kind == ParseNodeKind::RegExpExpr ||
           kind == ParseNodeKind::TemplateStringExpr ||
+          kind == ParseNodeKind::TemplateStringListExpr ||
           kind == ParseNodeKind::RawUndefinedExpr || pn->isInParens();
 
       // https://tc39.es/ecma262/#sec-left-hand-side-expressions
       bool isMemberExpression = isPrimaryExpression ||
                                 kind == ParseNodeKind::TaggedTemplateExpr ||
                                 kind == ParseNodeKind::NewExpr ||
                                 kind == ParseNodeKind::NewTargetExpr ||
                                 kind == ParseNodeKind::ImportMetaExpr;
--- a/js/src/tests/non262/expressions/optional-chain.js
+++ b/js/src/tests/non262/expressions/optional-chain.js
@@ -43,16 +43,29 @@ function shouldThrowTypeError(func, mess
     }
 
     if (!(error instanceof TypeError))
         throw new Error('Expected TypeError!');
 
     if (!error.message.includes(messagePrefix))
         throw new Error(`TypeError has wrong message!, expected ${messagePrefix} but got ${error.message}`);
 }
+
+function shouldThrowReferenceError(script) {
+    let error;
+    try {
+        eval(script);
+    } catch (e) {
+        error = e;
+    }
+
+    if (!(error instanceof ReferenceError))
+        throw new Error('Expected ReferenceError!');
+}
+
 function testBasicSuccessCases() {
     shouldBe(undefined?.valueOf(), undefined);
     shouldBe(null?.valueOf(), undefined);
     shouldBe(true?.valueOf(), true);
     shouldBe(false?.valueOf(), false);
     shouldBe(0?.valueOf(), 0);
     shouldBe(1?.valueOf(), 1);
     shouldBe(''?.valueOf(), '');
@@ -167,16 +180,17 @@ shouldThrowSyntaxError('class C {} class
 shouldThrowSyntaxError('class C {} class D extends C { foo() { return super?.["bar"]; } }');
 shouldThrowSyntaxError('class C {} class D extends C { constructor() { super?.(); } }');
 shouldThrowSyntaxError('const o = { C: class {} }; new o?.C();')
 shouldThrowSyntaxError('const o = { C: class {} }; new o?.["C"]();')
 shouldThrowSyntaxError('class C {} new C?.();')
 shouldThrowSyntaxError('function foo() { new?.target; }');
 shouldThrowSyntaxError('function tag() {} tag?.``;');
 shouldThrowSyntaxError('const o = { tag() {} }; o?.tag``;');
+shouldThrowReferenceError('`${G}`?.r');
 
 // NOT an optional chain
 shouldBe(false?.4:5, 5);
 
 function testSideEffectCountFunction() {
   let count = 0;
   let a = {
     b: {