ModuleDeclarationInstantiation behaviour after failure

Jon Coppeard jcoppeard at
Wed Jul 6 10:02:17 UTC 2016

Fuzz testing has recently turned up some interesting behaviour involving

What currently happens is that ModuleDeclarationInstantiation always
initialises the source text module record's Environment slot, even if it
subsequently fails with an error (e.g. failure to resolve import).  This
leaves the environment partially initialised.

Then if it is called a second time for that module (maybe in the course
of recursively performing ModuleDeclarationInstantiation starting from a
different module) it will succeed without doing anything.  This can lead
to failure further on when code is executed without the expected
bindings being present.

Is this expected?

It seems to me that a subsequent call should either attempt to create
the environment again (maybe all dependencies are now available?) or
fail immediately in the same way.

The former could be accomplished by only setting the Environment slot at
the end after the environment has been successfully initialised.


More information about the es-discuss mailing list