Skip to content

Commit

Permalink
[JSC] parseMemberExpression() should create NewExpr with expression s…
Browse files Browse the repository at this point in the history
…tart location

https://bugs.webkit.org/show_bug.cgi?id=268022
<rdar://problem/121544630>

Reviewed by Yusuke Suzuki and Justin Michaud.

This was the idea of https://bugs.webkit.org/show_bug.cgi?id=267728, yet unfortunately in-between
implementation revisions the case of correct location for `new new new C` did regress.

* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseMemberExpression):

Canonical link: https://commits.webkit.org/273440@main
  • Loading branch information
Alexey Shvayka committed Jan 24, 2024
1 parent fb1c6b2 commit 27567fb
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Source/JavaScriptCore/parser/Parser.cpp
Expand Up @@ -5311,14 +5311,13 @@ template <class TreeBuilder> TreeExpression Parser<LexerType>::parseMemberExpres
{
TreeExpression base = 0;
JSTextPosition expressionStart = tokenStartPosition();
JSTokenLocation startLocation = tokenLocation();
JSTokenLocation location = tokenLocation();
Vector<JSTextPosition> newTokenStartPositions;
while (match(NEW)) {
newTokenStartPositions.append(tokenStartPosition());
next();
}
size_t newCount = newTokenStartPositions.size();
JSTokenLocation location = tokenLocation();

bool baseIsSuper = match(SUPER);
bool previousBaseWasSuper = false;
Expand All @@ -5337,7 +5336,7 @@ template <class TreeBuilder> TreeExpression Parser<LexerType>::parseMemberExpres
semanticFailIfFalse(!closestOrdinaryFunctionScope->isGlobalCode() || isFunctionEvalContextType || isClassFieldInitializer, "new.target is not valid inside arrow functions in global code");
currentScope()->setInnerArrowFunctionUsesNewTarget();
}
base = context.createNewTargetExpr(startLocation);
base = context.createNewTargetExpr(location);
newCount--;
next();
} else {
Expand Down

0 comments on commit 27567fb

Please sign in to comment.