Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ flags: [module]

$DONOTEVALUATE();

export { x as y } from './instn-iee-err-ambiguous_FIXTURE.js';
export { x as y } from './error-export-from-named_FIXTURE.js';
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ flags: [module]

$DONOTEVALUATE();

export { x } from './instn-iee-err-ambiguous_FIXTURE.js';
export { x } from './error-export-from-named_FIXTURE.js';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

export * from './instn-iee-err-ambiguous-1_FIXTURE.js';
export * from './instn-iee-err-ambiguous-2_FIXTURE.js';
export * from './error-export-from-named-1_FIXTURE.js';
export * from './error-export-from-named-2_FIXTURE.js';
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ flags: [module]

$DONOTEVALUATE();

import { x } from './instn-named-err-ambiguous_FIXTURE.js';
import { x as y } from './error-import-named_FIXTURE.js';
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ flags: [module]

$DONOTEVALUATE();

import { x as y } from './instn-named-err-ambiguous_FIXTURE.js';
import { x } from './error-import-named_FIXTURE.js';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

export * from './instn-star-ambiguous-1_FIXTURE.js';
export * from './instn-star-ambiguous-2_FIXTURE.js';
export * from './error-import-named-1_FIXTURE.js';
export * from './error-import-named-2_FIXTURE.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: A binding re-exported with `export { foo } from` and `import { foo } from; export { foo }` does not cause ambiguity.
esid: sec-source-text-module-record-initialize-environment
info: |
[...]
7. For each ImportEntry Record in of module.[[ImportEntries]], do
a. Let importedModule be GetImportedModule(module, in.[[ModuleRequest]]).
b. If in.[[ImportName]] is namespace-object, then
i. Let namespace be GetModuleNamespace(importedModule).
ii. Perform ! env.CreateImmutableBinding(in.[[LocalName]], true).
iii. Perform ! env.InitializeBinding(in.[[LocalName]], namespace).
c. Else,
i. Let resolution be importedModule.ResolveExport(in.[[ImportName]]).
ii. If resolution is either null or ambiguous, throw a SyntaxError exception.
Table 59 (Informative): Export Forms Mappings to ExportEntry Records
Export Statement Form [[ExportName]] [[ModuleRequest]] [[ImportName]] [[LocalName]]
export {x}; "x" null null "x"
export {x} from "mod"; "x" "mod" "x" null
16.2.1.7.1 ParseModule ( sourceText, realm, hostDefined )
[...]
10. For each ExportEntry Record ee of exportEntries, do
1. If ee.[[ModuleRequest]] is null, then
i. If importedBoundNames does not contain ee.[[LocalName]], then
1. Append ee to localExportEntries.
ii. Else,
1. Let ie be the element of importEntries whose [[LocalName]] is ee.[[LocalName]].
2. If ie.[[ImportName]] is namespace-object, then
a. NOTE: This is a re-export of an imported module namespace object.
b. Append ee to localExportEntries.
3. Else,
a. NOTE: This is a re-export of a single name.
b. Append the ExportEntry Record { [[ModuleRequest]]: ie.[[ModuleRequest]],
[[ImportName]]: ie.[[ImportName]], [[LocalName]]: null, [[ExportName]]:
ee.[[ExportName]] } to indirectExportEntries.
2. Else if ee.[[ImportName]] is all-but-default, then
[...]
3. Else,
a. Append ee to indirectExportEntries.
15.2.1.16.3 ResolveExport
[...]
6. For each ExportEntry Record e of module.[[IndirectExportEntries]], do
a. If e.[[ExportName]] is exportName, then
i. Assert: e.[[ModuleRequest]] is not null.
ii. Let importedModule be GetImportedModule(module, e.[[ModuleRequest]]).
iii. If e.[[ImportName]] is all, then
1. Assert: module does not provide the direct binding for this export.
2. Return ResolvedBinding Record { [[Module]]: importedModule, [[BindingName]]: namespace }.
[...]
9. Let starResolution be null.
10. For each ExportEntry Record e in module.[[StarExportEntries]], do
a. Let importedModule be GetImportedModule(module,
e.[[ModuleRequest]]).
b. Let resolution be ? importedModule.ResolveExport(exportName,
resolveSet, exportStarSet).
c. If resolution is ~ambiguous~, return ~ambiguous~.
d. If resolution is not null, then
i. If starResolution is null, let starResolution be resolution.
ii. Else,
1. Assert: there is more than one * import that includes the
requested name.
2. If _resolution_.[[Module]] and _starResolution_.[[Module]] are
not the same Module Record, return ~ambiguous~.
3. If _resolution_.[[BindingName]] is not _starResolution_.[[BindingName]],
return ~ambiguous~.
flags: [module]
---*/

export * from "./import-and-export-propagates-binding_export-from_FIXTURE.js";
export * from "./import-and-export-propagates-binding_import-and-export_FIXTURE.js";

import { foo } from './import-and-export-propagates-binding.js';

assert.sameValue(foo, 2);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

export const foo = 2;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

export { foo } from "./import-and-export-propagates-binding_FIXTURE.js";
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

import { foo } from "./import-and-export-propagates-binding_FIXTURE.js";
export { foo };
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Statements `export * as foo` and `import * as foo; export { foo }` are different bindings
esid: sec-source-text-module-record-initialize-environment
info: |
[...]
7. For each ImportEntry Record in of module.[[ImportEntries]], do
a. Let importedModule be GetImportedModule(module, in.[[ModuleRequest]]).
b. If in.[[ImportName]] is namespace-object, then
i. Let namespace be GetModuleNamespace(importedModule).
ii. Perform ! env.CreateImmutableBinding(in.[[LocalName]], true).
iii. Perform ! env.InitializeBinding(in.[[LocalName]], namespace).
c. Else,
i. Let resolution be importedModule.ResolveExport(in.[[ImportName]]).
ii. If resolution is either null or ambiguous, throw a SyntaxError exception.

Table 59 (Informative): Export Forms Mappings to ExportEntry Records

Export Statement Form [[ExportName]] [[ModuleRequest]] [[ImportName]] [[LocalName]]
export {x}; "x" null null "x"
export * as ns from "mod"; "ns" "mod" all null

16.2.1.7.1 ParseModule ( sourceText, realm, hostDefined )
[...]
10. For each ExportEntry Record ee of exportEntries, do
1. If ee.[[ModuleRequest]] is null, then
i. If importedBoundNames does not contain ee.[[LocalName]], then
1. Append ee to localExportEntries.
ii. Else,
1. Let ie be the element of importEntries whose [[LocalName]] is ee.[[LocalName]].
2. If ie.[[ImportName]] is namespace-object, then
a. NOTE: This is a re-export of an imported module namespace object.
b. Append ee to localExportEntries.
3. Else,
a. NOTE: This is a re-export of a single name.
b. Append the ExportEntry Record { [[ModuleRequest]]: ie.[[ModuleRequest]],
[[ImportName]]: ie.[[ImportName]], [[LocalName]]: null, [[ExportName]]:
ee.[[ExportName]] } to indirectExportEntries.
2. Else if ee.[[ImportName]] is all-but-default, then
[...]
3. Else,
a. Append ee to indirectExportEntries.

15.2.1.16.3 ResolveExport

[...]
6. For each ExportEntry Record e of module.[[IndirectExportEntries]], do
a. If e.[[ExportName]] is exportName, then
i. Assert: e.[[ModuleRequest]] is not null.
ii. Let importedModule be GetImportedModule(module, e.[[ModuleRequest]]).
iii. If e.[[ImportName]] is all, then
1. Assert: module does not provide the direct binding for this export.
2. Return ResolvedBinding Record { [[Module]]: importedModule, [[BindingName]]: namespace }.
[...]
9. Let starResolution be null.
10. For each ExportEntry Record e in module.[[StarExportEntries]], do
a. Let importedModule be GetImportedModule(module,
e.[[ModuleRequest]]).
b. Let resolution be ? importedModule.ResolveExport(exportName,
resolveSet, exportStarSet).
c. If resolution is ~ambiguous~, return ~ambiguous~.
d. If resolution is not null, then
i. If starResolution is null, let starResolution be resolution.
ii. Else,
1. Assert: there is more than one * import that includes the
requested name.
2. If _resolution_.[[Module]] and _starResolution_.[[Module]] are
not the same Module Record, return ~ambiguous~.
3. If _resolution_.[[BindingName]] is not _starResolution_.[[BindingName]],
return ~ambiguous~.
negative:
phase: resolution
type: SyntaxError
flags: [module]
---*/

$DONOTEVALUATE();

export * from "./namespace-export-star-as-from-1_FIXTURE.js";
export * from "./namespace-import-star-as-and-export-1_FIXTURE.js";

import { foo } from './namespace-ambiguous-if-import-star-as-and-export.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Two copies of `import * as foo; export { foo }` are different bindings
esid: sec-source-text-module-record-initialize-environment
info: |
[...]
7. For each ImportEntry Record in of module.[[ImportEntries]], do
a. Let importedModule be GetImportedModule(module, in.[[ModuleRequest]]).
b. If in.[[ImportName]] is namespace-object, then
i. Let namespace be GetModuleNamespace(importedModule).
ii. Perform ! env.CreateImmutableBinding(in.[[LocalName]], true).
iii. Perform ! env.InitializeBinding(in.[[LocalName]], namespace).
c. Else,
i. Let resolution be importedModule.ResolveExport(in.[[ImportName]]).
ii. If resolution is either null or ambiguous, throw a SyntaxError exception.

Table 59 (Informative): Export Forms Mappings to ExportEntry Records

Export Statement Form [[ExportName]] [[ModuleRequest]] [[ImportName]] [[LocalName]]
export {x}; "x" null null "x"
export * as ns from "mod"; "ns" "mod" all null

16.2.1.7.1 ParseModule ( sourceText, realm, hostDefined )
[...]
10. For each ExportEntry Record ee of exportEntries, do
1. If ee.[[ModuleRequest]] is null, then
i. If importedBoundNames does not contain ee.[[LocalName]], then
1. Append ee to localExportEntries.
ii. Else,
1. Let ie be the element of importEntries whose [[LocalName]] is ee.[[LocalName]].
2. If ie.[[ImportName]] is namespace-object, then
a. NOTE: This is a re-export of an imported module namespace object.
b. Append ee to localExportEntries.
3. Else,
a. NOTE: This is a re-export of a single name.
b. Append the ExportEntry Record { [[ModuleRequest]]: ie.[[ModuleRequest]],
[[ImportName]]: ie.[[ImportName]], [[LocalName]]: null, [[ExportName]]:
ee.[[ExportName]] } to indirectExportEntries.
2. Else if ee.[[ImportName]] is all-but-default, then
[...]
3. Else,
a. Append ee to indirectExportEntries.

15.2.1.16.3 ResolveExport

[...]
6. For each ExportEntry Record e of module.[[IndirectExportEntries]], do
a. If e.[[ExportName]] is exportName, then
i. Assert: e.[[ModuleRequest]] is not null.
ii. Let importedModule be GetImportedModule(module, e.[[ModuleRequest]]).
iii. If e.[[ImportName]] is all, then
1. Assert: module does not provide the direct binding for this export.
2. Return ResolvedBinding Record { [[Module]]: importedModule, [[BindingName]]: namespace }.
[...]
9. Let starResolution be null.
10. For each ExportEntry Record e in module.[[StarExportEntries]], do
a. Let importedModule be GetImportedModule(module,
e.[[ModuleRequest]]).
b. Let resolution be ? importedModule.ResolveExport(exportName,
resolveSet, exportStarSet).
c. If resolution is ~ambiguous~, return ~ambiguous~.
d. If resolution is not null, then
i. If starResolution is null, let starResolution be resolution.
ii. Else,
1. Assert: there is more than one * import that includes the
requested name.
2. If _resolution_.[[Module]] and _starResolution_.[[Module]] are
not the same Module Record, return ~ambiguous~.
3. If _resolution_.[[BindingName]] is not _starResolution_.[[BindingName]],
return ~ambiguous~.
negative:
phase: resolution
type: SyntaxError
flags: [module]
---*/

$DONOTEVALUATE();

export * from "./namespace-import-star-as-and-export-1_FIXTURE.js";
export * from "./namespace-import-star-as-and-export-2_FIXTURE.js";

import { foo } from './namespace-ambiguous-if-import-star-as-and-export.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

export * as foo from "./namespace-empty-module_FIXTURE.js";
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

export * as foo from "./namespace-empty-module_FIXTURE.js";
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

import * as foo from "./namespace-empty-module_FIXTURE.js";
export { foo };
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

import * as foo from "./namespace-empty-module_FIXTURE.js";
export { foo };
Loading