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
12 changes: 7 additions & 5 deletions lib/Runtime/Language/SourceTextModuleRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,11 +842,6 @@ namespace Js
Assert(childModuleRecord->WasParsed());
childModuleRecord->ModuleDeclarationInstantiation();
});

childrenModuleSet->EachValue([=](SourceTextModuleRecord* childModuleRecord)
{
childModuleRecord->GenerateRootFunction();
});
}

ENTER_SCRIPT_IF(scriptContext, true, false, false, !scriptContext->GetThreadContext()->IsScriptActive(),
Expand Down Expand Up @@ -903,6 +898,13 @@ namespace Js
scriptContext->GetDebugContext()->RegisterFunction(this->rootFunction->GetFunctionBody(), nullptr);
}
#endif
if (childrenModuleSet != nullptr)
{
childrenModuleSet->EachValue([=](SourceTextModuleRecord* childModuleRecord)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this was copied from before, but since this doesnt need to capture anything in the outer scope, much less everything, could we remove the [=] to do so?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to access the childrenModuleSet within the EachValue function - which in turn uses it to populate the childModuleRecord.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except in the lambda body, only childModuleRecord is referenced, which is passed as a parameter to the lambda. Nothing from the lexical scope is used. With that being said, I just looked again at http://en.cppreference.com/w/cpp/language/lambda and it looks like the capture-all groups still only capture what is required in the lambda body, so there ends up being no actual runtime effect here -- my bad.

{
childModuleRecord->GenerateRootFunction();
});
}
}

Var SourceTextModuleRecord::ModuleEvaluation()
Expand Down
9 changes: 6 additions & 3 deletions test/es6/module_4482_dep1.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
//v) Thing2 would not yet exist = segfault


import Thing1 from './module_4482_dep2.js';
import Thing2 from './module_4482_dep3.js';
import Thing1 from 'module_4482_dep2.js';
import Thing2 from 'module_4482_dep3.js';

export { Thing1, Thing2 };

export default
function main()
{}
{
Thing1();
Thing2();
}
4 changes: 2 additions & 2 deletions test/es6/module_4482_dep2.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
//-------------------------------------------------------------------------------------------------------

//thing1.js
import { Thing2 } from './module_4482_dep1.js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not super familiar with this bug, but is removing the ./ relevant or important?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "./" isn't important, I just cleaned it up whilst doing this.

import { Thing2 } from 'module_4482_dep1.js';

export default
function Thing1()
function main()
{
Thing2();
}
7 changes: 5 additions & 2 deletions test/es6/module_4482_dep3.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
//-------------------------------------------------------------------------------------------------------


import { Thing1 } from './module_4482_dep1.js';
import { Thing1 } from 'module_4482_dep1.js';

export default
function Thing2(){}
function main()
{
Thing1();
}