How can GetModuleNamespace throw a SyntaxError?

Isiah Meadows isiahmeadows at gmail.com
Thu Dec 10 19:43:31 UTC 2015


 @Caridy: Then what does ResolveExport do in the ES6 spec? Or is it
basically dead code?

On Thu, Dec 10, 2015 at 2:27 PM, Caridy Patiño <caridy at gmail.com> wrote:
> Isiah: your example triggers a different error. ResolveExport is taking care
> of detecting that particular case
> (https://whatwg.github.io/loader/#resolve-export), it is also a SyntaxError
> :)
>
> Jon: yes, it might be a redundant error, I will investigate more.
>
> /caridy
>
>
> On Dec 9, 2015, at 10:11 PM, Isiah Meadows <isiahmeadows at gmail.com> wrote:
>
> It has to do with circular exported bindings. And IMHO a SyntaxError
> is the wrong error to throw (it should really throw a ReferenceError,
> as it's a circular reference).
>
> ```js
> // foo.js
> export {name} from "./bar.js"
> ```
>
> ```js
> // bar.js
> export {name} from "./foo.js"
> ```
>
> ```js
> // main.js
> import * as foo from "./foo.js" // Error!
> ```
>
> See the note in 15.2.1.16.3:
> http://www.ecma-international.org/ecma-262/6.0/#sec-resolveexport.
> That should help you.
>
> On Wed, Dec 9, 2015 at 2:44 PM, Jon Coppeard <jcoppeard at mozilla.com> wrote:
>
> In the definition of GetModuleNamespace (section 15.2.1.18), a
> SyntaxError is thrown if we fail to resolve an exported name:
>
> 3.d.iii If resolution is null, throw a SyntaxError exception.
>
>
> What situation leads to this error?
>
> I wasn't able to come up with an example that would make this happen,
> and my attempts all generated a SyntaxError at an earlier point.  It
> seems that GetExportedNames should only return names that will
> successfully resolve, but I may be missing something.
>
> Thanks,
>
> Jon
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
>
>
> --
> Isiah Meadows
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>



-- 
Isiah Meadows


More information about the es-discuss mailing list