Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions lib/Parser/Parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11440,11 +11440,18 @@ ParseNode* Parser::CopyPnode(ParseNode *pnode) {
return pnode;
//PTNODE(knopFalse , "false" ,False ,None ,fnopLeaf)
case knopFalse:
return CreateNodeT<knopFalse>(pnode->ichMin,pnode->ichLim);
break;
{
ParseNode* ret = CreateNodeT<knopFalse>(pnode->ichMin, pnode->ichLim);
ret->location = pnode->location;
return ret;
}
//PTNODE(knopTrue , "true" ,True ,None ,fnopLeaf)
case knopTrue:
return CreateNodeT<knopTrue>(pnode->ichMin,pnode->ichLim);
{
ParseNode* ret = CreateNodeT<knopTrue>(pnode->ichMin, pnode->ichLim);
ret->location = pnode->location;
return ret;
}
//PTNODE(knopEmpty , "empty" ,Empty ,None ,fnopLeaf)
case knopEmpty:
return CreateNodeT<knopEmpty>(pnode->ichMin,pnode->ichLim);
Expand Down Expand Up @@ -11574,8 +11581,8 @@ ParseNode* Parser::CopyPnode(ParseNode *pnode) {
//PTNODE(knopNew , "new" ,None ,Bin ,fnopBin)
case knopNew:
case knopCall:
return CreateCallNode(pnode->nop,CopyPnode(pnode->sxBin.pnode1),
CopyPnode(pnode->sxBin.pnode2),pnode->ichMin,pnode->ichLim);
return CreateCallNode(pnode->nop,CopyPnode(pnode->sxCall.pnodeTarget),
CopyPnode(pnode->sxCall.pnodeArgs),pnode->ichMin,pnode->ichLim);
//PTNODE(knopQmark , "?" ,None ,Tri ,fnopBin)
case knopQmark:
return CreateTriNode(pnode->nop,CopyPnode(pnode->sxTri.pnode1),
Expand Down
21 changes: 21 additions & 0 deletions test/Bugs/invertloop_bug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

// Triggering invertloop codepath and ensuring the copying of nodes happens correctly.

function foo() {
for (var a = 0; a < 1; ++a) {
for (var b = 0; b < 11; ++b) {
(true());
}
};

};

try {
foo();
} catch(e) {
print(e.message === 'Function expected' ? 'pass' : 'fail');
}
6 changes: 6 additions & 0 deletions test/Bugs/rlexe.xml
Original file line number Diff line number Diff line change
Expand Up @@ -324,4 +324,10 @@
<compile-flags>-simdjs -asmjs -testtrace:asmjs -asmjsstoponerror</compile-flags>
</default>
</test>
<test>
<default>
<files>invertloop_bug.js</files>
<tags>exclude_dynapogo</tags>
</default>
</test>
</regress-exe>