Skip to content

CyclicModuleRecord's Evaluate method attempts to use empty CycleRoot when called again after an evaluation error #2823

@jonco3

Description

@jonco3

Take for example the module 'a' which simply throws:

throw 1;

After calling Evaluate the module will have Status |evaluated| and CycleRoot |empty|. The former is set by Evaluate step 9.a.ii and the latter is not set because InnerModuleEvaluation step 13 performs ReturnIfAbrupt on the result of ExecuteModule before this can happen.

If EvaluateModule is called a second time on the same module, we will set the module variable to the empty CycleRoot in step 3 and then attempt to access its fields in step 4.

The same problem arises if a second module 'b' that imports the former module is evaluated:

import {} from "a";

This time we access the CycleRoot field in InnerModuleEvaluation step 11.d.iv.1.

For synchronously executed modules, evaluation terminates in InnerModuleEvaluation before cycles have been identified, so it's reasonable to expect CycleRoot to be empty for a module with status evaluated if EvaluationError has been set.

I believe it is valid to call Execute twice for the same module. The description implies this when it says "The first time it is called on a module in a given strongly connected component". (The description also say "Evaluate transitions this module's Status from linked to either evaluating-async or evaluated" which implies the opposite, however that conflicts with the assertion in step 2 which allows it to be called on modules in any of those states, not just linked.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions