Skip to content

Commit bdf25ed

Browse files
committed
Track assignments in some missing corner cases
1 parent 75cfe99 commit bdf25ed

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lib/Parser/Parse.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3229,6 +3229,9 @@ ParseNodePtr Parser::ParseTerm(BOOL fAllowCall,
32293229
// Super call needs to reference 'new.target'
32303230
if (pid == wellKnownPropertyPids._superConstructor)
32313231
{
3232+
// super() will write to "this", so track the assignment.
3233+
PidRefStack *thisRef = wellKnownPropertyPids._this->GetTopRef();
3234+
thisRef->isAsg = true;
32323235
ReferenceSpecialName(wellKnownPropertyPids._newTarget, ichMin, ichLim);
32333236
}
32343237

@@ -10149,7 +10152,9 @@ ParseNodePtr Parser::ParseStatement()
1014910152
}
1015010153
else
1015110154
{
10152-
pnodeT = ParseExpr<buildAST>(koplNo, &fCanAssign, /*fAllowIn = */FALSE);
10155+
IdentToken token;
10156+
pnodeT = ParseExpr<buildAST>(koplNo, &fCanAssign, /*fAllowIn = */FALSE, FALSE, NULL, nullptr, nullptr, &token);
10157+
TrackAssignment<buildAST>(pnodeT, &token);
1015310158
}
1015410159

1015510160
// We would veryfiy the grammar as destructuring grammar only when for..in/of case. As in the native for loop case the above ParseExpr call
@@ -12701,10 +12706,6 @@ ParseNodePtr Parser::ConvertArrayToArrayPattern(ParseNodePtr pnode)
1270112706
{
1270212707
*itemRef = ConvertObjectToObjectPattern(item);
1270312708
}
12704-
else if (item->nop == knopName)
12705-
{
12706-
TrackAssignment<true>(item, nullptr);
12707-
}
1270812709
});
1270912710

1271012711
return pnode;
@@ -12741,11 +12742,7 @@ ParseNodePtr Parser::GetRightSideNodeFromPattern(ParseNodePtr pnode)
1274112742
else
1274212743
{
1274312744
rightNode = pnode;
12744-
if (op == knopName)
12745-
{
12746-
TrackAssignment<true>(pnode, nullptr);
12747-
}
12748-
else if (op == knopAsg)
12745+
if (op == knopAsg)
1274912746
{
1275012747
TrackAssignment<true>(pnode->AsParseNodeBin()->pnode1, nullptr);
1275112748
}
@@ -13050,6 +13047,8 @@ ParseNodePtr Parser::ParseDestructuredVarDecl(tokens declarationType, bool isDec
1305013047
Error(ERRInvalidAssignmentTarget);
1305113048
}
1305213049

13050+
TrackAssignment<buildAST>(pnodeElem, &token);
13051+
1305313052
if (buildAST)
1305413053
{
1305513054
if (IsStrictMode() && pnodeElem != nullptr && pnodeElem->nop == knopName)

0 commit comments

Comments
 (0)