From 99a19f39e7f16d666ebe49e83fd7a86bab7358b2 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 15 Aug 2018 23:23:21 +0200 Subject: [PATCH 1/2] throw for uninstantiated dynamic module access --- spec.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spec.html b/spec.html index be911c0..69df3bd 100644 --- a/spec.html +++ b/spec.html @@ -101,6 +101,8 @@

GetExportedNames ( _exportStarSet_, _starExportModule_ ) Concrete 1. For each ExportEntry Record _e_ in _module_.[[StarExportEntries]], do 1. Let _requestedModule_ be ? HostResolveImportedModule(_module_, _e_.[[ModuleRequest]]). 1. Let _starNames_ be ? _requestedModule_.GetExportedNames(_exportStarSet_, _starExportModule_). + 1. If _starNames_ is *null* then, + 1. Return *null*. 1. For each element _n_ of _starNames_, do 1. If SameValue(_n_, `"default"`) is *false*, then 1. If _n_ is not an element of _exportedNames_, then @@ -194,6 +196,8 @@

GetExportedNames ( _exportStarSet_, _starExportModule_ ) Concrete Method

It performs the following steps:

1. Let _module_ be this Dynamic Module Record. + 1. If _module_.[[Status]] is `"uninstantiated"` then, + 1. Return *null*. 1. If _module_.[[StarExportModules]] does not contain _starExportModule_ then, 1. Add _starExportModule_ to _module_.[[StarExportModules]]. 1. Return _module_.[[exportNames]]. @@ -210,6 +214,8 @@

ResolveExport ( _exportName_, _resolveSet_ ) Concrete Method

1. Let _module_ be this Dynamic Module Record. + 1. If _module_.[[Status]] is `"uninstantiated"` then, + 1. Perform ? _module_.Instantiate(). 1. Let _exportNames_ be _module_.[[ExportNames]]. 1. If _exportNames_ does not contain _exportName_ then, 1. Let _envRec_ be the Module Environment Record _module_.[[Environment]] @@ -349,6 +355,8 @@

Runtime Semantics: GetModuleNamespace ( _module_ )

1. Let _namespace_ be _module_.[[Namespace]]. 1. If _namespace_ is *undefined*, then 1. Let _exportedNames_ be ? _module_.GetExportedNames(« », _module_). + 1. If _exportedNames_ is *null*, then + 1. Throw a *ReferenceError* exception 1. Let _unambiguousNames_ be a new empty List. 1. For each _name_ that is an element of _exportedNames_, do 1. Let _resolution_ be ? _module_.ResolveExport(_name_, « »). @@ -357,7 +365,7 @@

Runtime Semantics: GetModuleNamespace ( _module_ )

1. Return _namespace_.
-

The only way GetModuleNamespace can throw is via one of the triggered HostResolveImportedModule calls. Unresolvable names are simply excluded from the namespace at this point. They will lead to a real instantiation error later unless they are all ambiguous star exports that are not explicitly requested anywhere.

+

The only way GetModuleNamespace can throw is either via one of the triggered HostResolveImportedModule calls or by attempting to resolve export names from an uninstantiated Dynamic Module Record. Unresolvable names to Source Text Modules are simply excluded from the namespace at this point. They will lead to a real instantiation error later unless they are all ambiguous star exports that are not explicitly requested anywhere.

From e121fe77de3f49fb9bbb09209dc2c5cbf34c96f5 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Thu, 16 Aug 2018 15:07:37 +0200 Subject: [PATCH 2/2] clarify dynamic error case --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index 69df3bd..2b4daac 100644 --- a/spec.html +++ b/spec.html @@ -365,7 +365,7 @@

Runtime Semantics: GetModuleNamespace ( _module_ )

1. Return _namespace_.
-

The only way GetModuleNamespace can throw is either via one of the triggered HostResolveImportedModule calls or by attempting to resolve export names from an uninstantiated Dynamic Module Record. Unresolvable names to Source Text Modules are simply excluded from the namespace at this point. They will lead to a real instantiation error later unless they are all ambiguous star exports that are not explicitly requested anywhere.

+

The only way GetModuleNamespace can throw is either via one of the triggered HostResolveImportedModule calls or by attempting to resolve export names from an uninstantiated Dynamic Module Record during a circular reference execution. Unresolvable names to Source Text Modules are simply excluded from the namespace at this point. They will lead to a real instantiation error later unless they are all ambiguous star exports that are not explicitly requested anywhere.