Commit cb387bc1 authored by Caitlin Potter's avatar Caitlin Potter Committed by Commit Bot

[parser] parse MemberExpression continuation after new.target

Keep parsing the rest of the MemberExpression after `new.target`

BUG=v8:6745
R=marja@chromium.org, adamk@chromium.org

Change-Id: I53cc370766e72ed9e36c5c7aa150a3ad9a6062f8
Reviewed-on: https://chromium-review.googlesource.com/627756Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Cr-Commit-Position: refs/heads/master@{#47615}
parent d0d84a5f
......@@ -3366,7 +3366,9 @@ ParserBase<Impl>::ParseMemberWithNewPrefixesExpression(bool* is_async,
*ok = false;
return impl()->NullExpression();
} else if (peek() == Token::PERIOD) {
return ParseNewTargetExpression(CHECK_OK);
*is_async = false;
result = ParseNewTargetExpression(CHECK_OK);
return ParseMemberExpressionContinuation(result, is_async, CHECK_OK);
} else {
result = ParseMemberWithNewPrefixesExpression(is_async, CHECK_OK);
}
......
......@@ -410,3 +410,65 @@ function get_new_target() { return new.target; }
assertThrows(function() { Function("++(new.target)"); }, ReferenceError);
assertThrows(function() { Function("for (new.target of {});"); }, SyntaxError);
})();
(function TestOperatorPrecedence() {
function A() {}
function constructNewTargetDotProp() { return new new.target.Prop }
constructNewTargetDotProp.Prop = A;
assertInstanceof(new constructNewTargetDotProp, A);
function constructNewTargetBracketProp() { return new new.target['Prop'] }
constructNewTargetBracketProp.Prop = A;
assertInstanceof(new constructNewTargetBracketProp, A);
function refNewTargetDotProp() { return new.target.Prop; }
function B() {}
refNewTargetDotProp.Prop = B;
assertEquals(new refNewTargetDotProp, B);
function refNewTargetBracketProp() { return new.target['Prop']; }
refNewTargetBracketProp.Prop = B;
assertEquals(new refNewTargetBracketProp, B);
var calls = 0;
function constructNewTargetArgsDotProp(safe) {
this.Prop = ++calls;
return safe ? Object(new new.target().Prop) : this;
}
assertInstanceof(new constructNewTargetArgsDotProp,
constructNewTargetArgsDotProp);
assertEquals(3, new constructNewTargetArgsDotProp(true) | 0);
function constructNewTargetArgsBracketProp(safe) {
this.Prop = ++calls;
return safe ? Object(new new.target()['Prop']) : this;
}
assertInstanceof(new constructNewTargetArgsBracketProp,
constructNewTargetArgsBracketProp);
assertEquals(6, new constructNewTargetArgsBracketProp(true) | 0);
function callNewTargetArgsDotProp(safe) {
this.Prop = ++calls;
return safe ? Object(new.target().Prop) : this;
}
assertInstanceof(new callNewTargetArgsDotProp(), callNewTargetArgsDotProp);
assertEquals(new callNewTargetArgsDotProp(true) | 0, 9);
function callNewTargetArgsBracketProp(safe) {
this.Prop = ++calls;
return safe ? Object(new.target()['Prop']) : this;
}
assertInstanceof(new callNewTargetArgsBracketProp(),
callNewTargetArgsBracketProp);
assertEquals(new callNewTargetArgsBracketProp(true) | 0, 12);
function tagNewTarget(callSite, ...subs) {
return callSite ? subs : new.target`${new.target.name}`;
}
assertEquals(new tagNewTarget, ["tagNewTarget"]);
function C(callSite, ...subs) { return subs; }
function tagNewTargetProp() { return new.target.Prop`${new.target.name}`; }
tagNewTargetProp.Prop = C;
assertEquals(new tagNewTargetProp, ["tagNewTargetProp"]);
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment