Description
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
- Support
inFunction
setting ofPerformEval
(see Step 6, 10.b.ii., and 11.e.) - Support
inMethod
setting ofPerformEval
(see Step 7, 10.b.iii., and 11.f.) - Support
inDerivedConstructor
setting ofPerformEval
(see Step 8, 10.b.iv., and 11.g.) - Support
inClassFieldInitializer
setting ofPerformEval
(see Step 9, 10.b.vi., and 11.h.) - Support
privateIdentifiers
setting ofEvalDeclarationInstantiation
(see Steps 4 through 7) - Support
strict
parsing of scripts (seePerformEval
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.