Mark S. Miller (2014-10-01T15:39:17.000Z)
domenic at domenicdenicola.com (2014-10-15T18:41:24.483Z)
On Wed, Oct 1, 2014 at 8:20 AM, Oliver Hunt <oliver at apple.com> wrote: > JSC does lazy parsing of nested functions and we have no problem reporting > static errors, so i’m not sure what you believe is the problem here. First, I agree with you. This shouldn't be a problem. However, both JSC and v8 cause confusion when they use the term "lazy parsing". There are plenty of static errors that could not be reported with a truly lazy parser, i.e., one which actually postpones parsing. v8 for example uses a lightweight but accurate parser that is supposed to catch early errors early, but, afaik, doesn't construct an actual ast. See - https://code.google.com/p/v8/issues/detail?id=2728 - https://code.google.com/p/v8/issues/detail?id=2470 - https://code.google.com/p/google-caja/issues/detail?id=1616 - https://bugs.webkit.org/show_bug.cgi?id=106160 (Oliver, I note that the last bug above is still open, which continues to cause SES to use an expensive workaround when run on Safari.) 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. If there is an intervening "with" or sloppy direct eval, then there is not a statically apparent assignment to a const variable. Since this can only occur in sloppy code anyway, it seems more consistent with the rest of sloppy mode for this failed assignment to be silent, rather than dynamically throwing an error.