Skip to content

parser/semantic: Support eval string parsing #11793

@aapoalas

Description

@aapoalas

Eval strings are parsed similarly to scripts but have a few edge cases that (arguably) require explicit support on the semantic analysis side. These originate from the specification's PerformEval and EvalDeclarationInstantiation abstract operations.

These are

  1. Support inFunction setting of PerformEval (see Step 6, 10.b.ii., and 11.e.)
  2. Support inMethod setting of PerformEval (see Step 7, 10.b.iii., and 11.f.)
  3. Support inDerivedConstructor setting of PerformEval (see Step 8, 10.b.iv., and 11.g.)
  4. Support inClassFieldInitializer setting of PerformEval (see Step 9, 10.b.vi., and 11.h.)
  5. Support privateIdentifiers setting of EvalDeclarationInstantiation (see Steps 4 through 7)
  6. Support strict parsing of scripts (see PerformEval strictCaller parameter)

Settings 1-5 are needed for full ECMAScript eval parsing support and cannot reasonably be implemented by an embedder, as supporting them would mean implementing a custom semantic analysis step from scratch. (It would be possible to perform normal semantic analysis on eval and check that any errors are permissible according to the 5 extra settings, and if they are then ignore the semantic analysis errors. This assumes that the semantic analysis will not short-circuit, though.)

Setting 6 is needed for parsing of eval scripts in strict contexts while ensuring that module declarations (imports, exports) are not allowed in. This is easy to check manually by an embedder as well, as it only requires filtering over the body statements directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions