Bug 1599163 - fix nullish coalescing operator for (void 0) case; r=jorendorff

Differential Revision: https://phabricator.services.mozilla.com/D54775

--HG--
extra : moz-landing-system : lando
This commit is contained in:
yulia 2019-11-26 18:47:20 +00:00
Родитель bb66a7c88e
Коммит eb71df2dc9
2 изменённых файлов: 2 добавлений и 0 удалений

Просмотреть файл

@ -718,6 +718,7 @@ static bool FoldAndOrCoalesce(JSContext* cx, ParseNode** nodePtr) {
bool isTruthyCoalesceNode =
isCoalesceNode && !((*elem)->isKind(ParseNodeKind::NullExpr) ||
(*elem)->isKind(ParseNodeKind::VoidExpr) ||
(*elem)->isKind(ParseNodeKind::RawUndefinedExpr));
bool canShortCircuit = (isOrNode && t == Truthy) ||
(isAndNode && t == Falsy) || isTruthyCoalesceNode;

Просмотреть файл

@ -67,6 +67,7 @@ shouldBe(1 * null ?? 3, 0);
shouldBe(1 / null ?? 3, Infinity);
shouldBe(isNaN(1 % null ?? 3), true);
shouldBe(1 ** null ?? 3, 1);
shouldBe((void 0) ?? 3, 3);
const obj = {
count: 0,