This repository has been archived by the owner on Feb 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Proposed specification changes incomplete #10
Comments
spectranaut
changed the title
Proposed specification changes incomplete -- reopen this proposal, close consensus PR?
Proposed specification changes incomplete
Mar 21, 2018
@dherman -- this is the problem I was asking you about on irc, if you are curious! :) |
cc @allenwb |
Hey @spectranaut! I've reviewed your write up, and it seems logical to me. I'm not the champion of this proposal, but I'd be happy to review a patch for you. Having an example of a fix (rather than a description of the problem) might make it easier for the other reviewers to comment. As you're now well-aware, this stuff is very tricky, especially if you've been away for a few months. |
Closing - the consensus PR was merged: tc39/ecma262#1174 🎉 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello @bterlson and @jdalton,
This proposal's spec change contains normative additions to the production and static semantics, but no modifications of the methods for the instantiation of modules. We will need a modification of these methods as presently the new syntax will always result in a SyntaxError during instantiation. Here's a walk through of instantiation of modules with the new production, to see the SyntaxError.
Consider the following three modules (with the relevant fields set in ParseModule):
a.js
a.js.[[LocalExportEntries]]
"x"
"x"
b.js
b.js.[[StarExportEntries]]:
"a.js"
"*"
"ns"
c.js
c.js.[[ImportEntries]]:
"b.js"
"ns"
"ns"
During the instantiation of module c.js, we arrive at ModuleDeclarationEnvironmentSetup for module c.js with the [[ImportEntries]] listed above. At this point, modules b.js and a.js have been instantiated.
From line 8.d.i above, we end up in ResolveExport with:
exportName = 'ns'
module='b.js'
Conclusion:
ResolveExport will always return null as we will never find
"ns"
in a.js. We go looking for"ns"
in a.js because b.js's export record with [[ImportName]]='*'
will trigger a look for the binding for"ns"
in a.js. In result, ModuleDeclarationEnvironmentSetup will always throw a SyntaxError when instantiating c.js.In addition to fixing this particular misdirection, we need to create a module namespace object for
"ns"
, as is done in ModuleDeclarationEnvironmentSetup line 8.c. There is no code path for this happening from anexport
statement -- onlyimport * as ns
will trigger the creation of a module namespace object.So, how can we handle
export * as ns from 'a.js'
?Perhaps we can add logic to ModuleDeclarationInstantiation to process all [[StarImportEntries]] with an [[ExporName]] after line 7. This will cause the creation of the module namespace object while instantiating b.js.
However, we'd also have to edit ResolveExport to handle these special [[StarImportEntries]] cases. It might makes more sense to add this export entry to the [[IndirectExportEntrie]] in ParseModule -- instead of the [[StarExporEntries]] -- as they are logically more similar. Still, both methods will have to be edited.
(Thanks to @jugglinmike for originally helping me though the module logic!)
The text was updated successfully, but these errors were encountered: