Skip to content

Commit 6311510

Browse files
committed
[1.9>master] [1.8>1.9] [MERGE #4583 @rhuanjl] Modules: Fix indirect circular children
Merge pull request #4583 from rhuanjl:moduleAgain This re-fixes #4482 Notes: 1. Test case was previously dependent on load order. Load order was changed which made the issue appear to be fixed (and test pass) when it wasn't actually fixed. - Test case revised to trigger issue irrespective of load order. 2. Have to complete all ModuleDeclarationInstantiation before we generate any root functions to ensure this issue can never occur. Conscious the test case may need moving to fit with #4582
2 parents bbc4c2e + 50e5667 commit 6311510

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

lib/Runtime/Language/SourceTextModuleRecord.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -842,11 +842,6 @@ namespace Js
842842
Assert(childModuleRecord->WasParsed());
843843
childModuleRecord->ModuleDeclarationInstantiation();
844844
});
845-
846-
childrenModuleSet->EachValue([=](SourceTextModuleRecord* childModuleRecord)
847-
{
848-
childModuleRecord->GenerateRootFunction();
849-
});
850845
}
851846

852847
ENTER_SCRIPT_IF(scriptContext, true, false, false, !scriptContext->GetThreadContext()->IsScriptActive(),
@@ -903,6 +898,13 @@ namespace Js
903898
scriptContext->GetDebugContext()->RegisterFunction(this->rootFunction->GetFunctionBody(), nullptr);
904899
}
905900
#endif
901+
if (childrenModuleSet != nullptr)
902+
{
903+
childrenModuleSet->EachValue([=](SourceTextModuleRecord* childModuleRecord)
904+
{
905+
childModuleRecord->GenerateRootFunction();
906+
});
907+
}
906908
}
907909

908910
Var SourceTextModuleRecord::ModuleEvaluation()

test/es6/module_4482_dep1.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@
1313
//v) Thing2 would not yet exist = segfault
1414

1515

16-
import Thing1 from './module_4482_dep2.js';
17-
import Thing2 from './module_4482_dep3.js';
16+
import Thing1 from 'module_4482_dep2.js';
17+
import Thing2 from 'module_4482_dep3.js';
1818

1919
export { Thing1, Thing2 };
2020

2121
export default
2222
function main()
23-
{}
23+
{
24+
Thing1();
25+
Thing2();
26+
}

test/es6/module_4482_dep2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
//-------------------------------------------------------------------------------------------------------
55

66
//thing1.js
7-
import { Thing2 } from './module_4482_dep1.js';
7+
import { Thing2 } from 'module_4482_dep1.js';
88

99
export default
10-
function Thing1()
10+
function main()
1111
{
1212
Thing2();
1313
}

test/es6/module_4482_dep3.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
//-------------------------------------------------------------------------------------------------------
55

66

7-
import { Thing1 } from './module_4482_dep1.js';
7+
import { Thing1 } from 'module_4482_dep1.js';
88

99
export default
10-
function Thing2(){}
10+
function main()
11+
{
12+
Thing1();
13+
}

0 commit comments

Comments
 (0)