archives

« Bugzilla Issues Index

#1204 — 11.2.4: Early error restriction for the 'super' keyword w.r.t. eval code contained in function code


The early errors restriction for [11.2.4 The super Keyword] currently specifies:
---
It is a Syntax Error if the source code parsed with this production is eval code and the source code is not being processed by a direct call to eval that is contained in function code.
---

This reads as if the following code should be allowed:
---
js> class Base { f(){return "base"} }
(void 0)
js> class Derived extends Base { f(){return "@" + eval("super.f()"); super.whatever_create_homeobject_entry} }
(void 0)
js> new Derived().f()
"@base"
---

However, `eval` parses the supplied source code with goal symbol Script [15.1.2.1 - step 2] and early errors for Script explicitly disallow super [14.1]:
---
It is a Syntax Error if OuterStatementList Contains super.
---


The definition of eval probably needs to be updated to account for the various context where a direct eval can occur.

May also need to adjust the meaning/usage of "function code"

allowing super to appear in eval code also complicates super binding of methods. Essentially every method that contains a direct eval needs to be super bound just in case it evals a super.


Fixed in rev30 editor's draft

Eliminated redundant static semantic rules about where super can occur. Only kept the rules in 15.1.1 (Script) and !5.2.1.1 (Module). In 15.1.1 may it explicit that the early error does not apply to eval code the is being processed by a direct eval from function code.


fixed in rev30