archives

« Bugzilla Issues Index

#3844 — super in eval


http://people.mozilla.org/~jorendorff/es6-draft.html#sec-scripts-static-semantics-early-errors

It is a Syntax Error if StatementList Contains super unless the source code containing super is eval code that is being processed by a direct eval that is contained in function code.

That means that:

function f() {
eval('super.x');
}

which is of course not what we we want.

We need to replace function code with something more elaborate. Something that encapsulates, methods, accessors, constuctors and nested arrow functions within those.


I'm semi-inclined to eliminate this as an early error. Evals by their very nature aren't really "early" and any use of super that isn't in a context where we allow super is going to throw when used.

We'd have to invent new ways to describe where super is or isn't allowed just for this case. It seems to me that for direct eval, the runtime error is good enough.

What do you think?


Fair enough.

If that is the case should we even check that the "eval code that is being processed by a direct eval that is contained in function code"?


(In reply to Erik Arvidsson from comment #2)
> Fair enough.
>
> If that is the case should we even check that the "eval code that is being
> processed by a direct eval that is contained in function code"?

we still need the function code check because a top level script execution context doesn't have all of the execution context state needed to check for a runtime super is valid

fixed in rev34