Skip to content

Commit

Permalink
Fix incorrect use of local vs import name in export entries
Browse files Browse the repository at this point in the history
  • Loading branch information
christianrondeau committed Mar 7, 2022
1 parent 1d415c5 commit d92d488
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
2 changes: 0 additions & 2 deletions Jint.Tests/Runtime/ModuleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ public void ShouldAllowExportMultipleImports()
Assert.Equal("1 2", ns.Get("result").AsString());
}

/* ECMAScript 2020 "export * as ns from"
[Fact]
public void ShouldAllowNamedStarExport()
{
Expand All @@ -204,7 +203,6 @@ public void ShouldAllowNamedStarExport()

Assert.Equal(5, ns.Get("ns").Get("value1").AsNumber());
}
*/

[Fact]
public void ShouldAllowChaining()
Expand Down
2 changes: 1 addition & 1 deletion Jint/EsprimaExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ internal static void GetExportEntries(this ExportDeclaration export, List<Export
for (var i = 0; i < specifiers.Count; i++)
{
var specifier = specifiers[i];
exportEntries.Add(new(specifier.Exported.GetModuleKey(), namedDeclaration.Source?.StringValue, specifier.Local.GetModuleKey(), null));
exportEntries.Add(new(specifier.Exported.GetModuleKey(), namedDeclaration.Source?.StringValue, namedDeclaration.Source != null ? specifier.Local.GetModuleKey() : null, specifier.Local.GetModuleKey()));
}
}

Expand Down
2 changes: 1 addition & 1 deletion Jint/Runtime/Modules/BuilderModuleRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected override void InitializeEnvironment()
{
var d = _exportBuilderDeclarations[i];
_environment.CreateImmutableBindingAndInitialize(d.Key, true, d.Value);
_localExportEntries.Add(new ExportEntry(d.Key, null, null, null));
_localExportEntries.Add(new ExportEntry(d.Key, null, null, d.Key));
}
_exportBuilderDeclarations.Clear();
}
Expand Down
4 changes: 2 additions & 2 deletions Jint/Runtime/Modules/SourceTextModuleRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ internal override ResolvedBinding ResolveExport(string exportName, List<ExportRe
if (exportName == e.ExportName)
{
// i. Assert: module provides the direct binding for this export.
return new ResolvedBinding(this, e.LocalName ?? e.ExportName);
return new ResolvedBinding(this, e.LocalName);
}
}

Expand All @@ -147,7 +147,7 @@ internal override ResolvedBinding ResolveExport(string exportName, List<ExportRe
else
{
// 1. Assert: module imports a specific binding for this export.
return importedModule.ResolveExport(e.ExportName, resolveSet);
return importedModule.ResolveExport(e.ImportName, resolveSet);
}
}
}
Expand Down

0 comments on commit d92d488

Please sign in to comment.