Skip to content
Closed
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
10 changes: 10 additions & 0 deletions lib/Runtime/Language/SourceTextModuleRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,11 @@ namespace Js

uint SourceTextModuleRecord::GetLocalExportSlotIndexByExportName(PropertyId exportNameId)
{
if(!this->WasDeclarationInitialized())//allow for circular imports that reference each other's functions
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: coding style isnt a big deal for us, but I think we usually avoid using this-> unless it is to avoid ambiguity.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Happy to remove though this-> is used 109 times in SourceTextModuleRecord so I was kinda copying what I'd seen there.

{
ModuleDeclarationInstantiation();
}

Assert(localSlotCount != 0);
Assert(localExportSlots != nullptr);
uint slotIndex = InvalidSlotIndex;
Expand All @@ -1160,6 +1165,11 @@ namespace Js

uint SourceTextModuleRecord::GetLocalExportSlotIndexByLocalName(PropertyId localNameId)
{
if(!this->WasDeclarationInitialized())//allow for circular imports that reference each other's functions
{
ModuleDeclarationInstantiation();
}

Assert(localSlotCount != 0 || localNameId == PropertyIds::star_);
Assert(localExportSlots != nullptr);
uint slotIndex = InvalidSlotIndex;
Expand Down
12 changes: 12 additions & 0 deletions test/es6/module-4482-bug-dep1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------


import {Thing2} from "./module-4482-bug.js";

export default function Thing1()
{
Thing2();
}
11 changes: 11 additions & 0 deletions test/es6/module-4482-bug-dep2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------


import {Thing1} from "./module-4482-bug.js";

export default function Thing2()
{
}
15 changes: 15 additions & 0 deletions test/es6/module-4482-bug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

import Thing1 from './module-4482-bug-dep1.js';
import Thing2 from './module-4482-bug-dep2.js';

export { Thing1, Thing2 };

export default function main()
{
Thing1();
Thing2();
}
8 changes: 8 additions & 0 deletions test/es6/module-functionality.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,14 @@ var tests = [
testModuleScript(functionBody);
}
},
{
name:"Inter-related circular dependencies",
body: function () {
let functionBody =
`import './module-4482-bug.js';`;
testModuleScript(functionBody);
}
},
{
name: "Implicitly re-exporting an import binding (import { foo } from ''; export { foo };)",
body: function () {
Expand Down