Throwing errors on mutating immutable bindings

Andreas Rossberg rossberg at google.com
Thu Oct 2 00:22:12 PDT 2014


On 1 October 2014 16:09, Erik Arvidsson <erik.arvidsson at gmail.com> wrote:
> The static error is problematic. I'm pretty sure that engines that do lazy
> parsing of functions is not going to report static errors before doing a
> full parse of the function.

Well, it is no harder than reporting reference errors for unbound
variables in strict mode, which is already required for ES5.
...However, at least V8 does not report that correctly either, as soon
as lazy parsing kicks in.


On 1 October 2014 17:39, Mark S. Miller <erights at google.com> wrote:
> So the question is not "Can this early error be reported accurately without
> parsing?", since essentially none can, so no engines postpone parsing. The
> question is whether a particular new early error would require these
> lightweight early parsers to do something that they can't do while
> preserving their current efficiency.
>
> Statically apparent assignment to const variables does not seem like a
> burden.

This analysis (as well as diagnosing unbound variables in strict mode)
requires more than just parsing -- it requires full binding analysis.
You have to construct all scope environments, analyse all
declarations, and track all variable uses, even during "lazy" parsing.
That has non-trivial complexity (although I don't know how costly it
is).

/Andreas


More information about the es-discuss mailing list