Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Issue 7983006: Fix pre-parsing function declarations. (Closed)

Created:
9 years, 3 months ago by Steven
Modified:
9 years, 3 months ago
Reviewers:
Lasse Reichstein
CC:
v8-dev
Visibility:
Public.

Description

Fix pre-parsing function declarations. The preparser has been out of sync with the parser. As a reminder, we have the following grammer for harmony mode Block :: { SourceElement* } SourceElement :: Statement FunctionDeclaration LetDeclaration instead of Block :: { Statement* } SourceElement :: Statement FunctionDeclaration The extension to allow FunctionDeclarations in statement positions in non-strict code is still active. Committed: http://code.google.com/p/v8/source/detail?r=9363

Patch Set 1 #

Total comments: 15
Unified diffs Side-by-side diffs Delta from patch set Stats (+101 lines, -39 lines) Patch
M src/parser.cc View 4 chunks +22 lines, -10 lines 0 comments Download
M src/preparser.cc View 5 chunks +30 lines, -28 lines 7 comments Download
M test/mjsunit/harmony/block-let-declaration.js View 1 chunk +49 lines, -1 line 8 comments Download

Messages

Total messages: 5 (0 generated)
Steven
PTAL.
9 years, 3 months ago (2011-09-21 09:00:04 UTC) #1
Lasse Reichstein
LGTM http://codereview.chromium.org/7983006/diff/1/src/preparser.cc File src/preparser.cc (right): http://codereview.chromium.org/7983006/diff/1/src/preparser.cc#newcode396 src/preparser.cc:396: return ParseStatement(CHECK_OK); CHECK_OK -> ok We won't be ...
9 years, 3 months ago (2011-09-21 10:29:34 UTC) #2
Steven
http://codereview.chromium.org/7983006/diff/1/src/preparser.cc File src/preparser.cc (right): http://codereview.chromium.org/7983006/diff/1/src/preparser.cc#newcode394 src/preparser.cc:394: (!strict_mode() || !expr.AsIdentifier().IsFutureReserved())) { While we are already here. ...
9 years, 3 months ago (2011-09-21 12:03:28 UTC) #3
Lasse Reichstein
http://codereview.chromium.org/7983006/diff/1/src/preparser.cc File src/preparser.cc (right): http://codereview.chromium.org/7983006/diff/1/src/preparser.cc#newcode394 src/preparser.cc:394: (!strict_mode() || !expr.AsIdentifier().IsFutureReserved())) { We "should" disallow FutureReserved in ...
9 years, 3 months ago (2011-09-21 20:11:45 UTC) #4
Steven
9 years, 3 months ago (2011-09-21 22:42:07 UTC) #5
http://codereview.chromium.org/7983006/diff/1/src/preparser.cc
File src/preparser.cc (right):

http://codereview.chromium.org/7983006/diff/1/src/preparser.cc#newcode394
src/preparser.cc:394: (!strict_mode() ||
!expr.AsIdentifier().IsFutureReserved())) {
Actually we do follow ES5 already and for labelled statements disallow the
correct sets of FutureReservedWords in both modes as specified in clause
7.6.1.2. I was just confused by this check because it did not make the
distinction between always FutureReservedWords and the ones that are only
reserved in strict mode. The check is actually redundant because
Parse(Primary)Expression will already disallow the usage. In fact I can use the
following assertions
if (expr.IsRawIdentifier()) {
  ASSERT(!expr.AsIdentifier().IsFutureReserved());
  ASSERT(!strict_mode() ||
         !expr.AsIdentifier().IsFutureStrictReserved());
  [...]

The file preparser/strict-identifiers.pyt does not yet include tests for
checking the identifier used in labelled statements, break or continue. And
indeed the implementations of break and continue both do not check the parsed
identifier, because clearly they use ParseIdentifier directly and not
ParseExpression.

On 2011/09/21 20:11:45, Lasse Reichstein wrote:
> We "should" disallow FutureReserved in non-strict mode, but we don't. It's a
> legacy thing - we can't start making future-reserved words an error now
without
> breaking code that uses them.
> We block keywords in both modes (expr.IsRawIdentifier() returns false on
> keywords), and future reserved words in strict mode.
> Both "eval" and "arguments" are allowed in both modes, since they are raw
> identifiers and not future reserved words.
> I.e., I believe the code does the right thing.
> 
> There is an extensive unit-test suite for the preparser. Do check if this
needs
> to be covered better.

Powered by Google App Engine
This is Rietveld 408576698