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

Issue 2109733003: Add errors for declarations which conflict with catch parameters. (Closed)

Created:
4 years, 5 months ago by bakkot
Modified:
4 years, 5 months ago
Reviewers:
Dan Ehrenberg, adamk
CC:
adamk, v8-reviews_googlegroups.com
Base URL:
https://chromium.googlesource.com/v8/v8.git@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

Add errors for declarations which conflict with catch parameters. Catch parameters are largely treated as lexical declarations in the block which contains their body for the purposes of early syntax errors, with some exceptions outlined in B.3.5. This patch introduces most of those errors, except those from `eval('for (var e of ...);')` inside of a catch with a simple parameter named 'e'. Note that annex B.3.5 allows var declarations to conflict with simple catch parameters, except when the variable declaration is the init of a for-of statement. BUG=v8:5112, v8:4231 Committed: https://crrev.com/2907c726b2bb5cf20b2bec639ca9e6a521585406 Cr-Commit-Position: refs/heads/master@{#37462}

Patch Set 1 #

Total comments: 4

Patch Set 2 : const correctness #

Patch Set 3 : add boolean #

Patch Set 4 : remove outdated 'const' language #

Patch Set 5 : rebase #

Patch Set 6 : better error messages #

Patch Set 7 : correct loop index #

Total comments: 7
Unified diffs Side-by-side diffs Delta from patch set Stats (+468 lines, -54 lines) Patch
M src/ast/scopes.h View 1 2 3 4 5 4 chunks +17 lines, -3 lines 2 comments Download
M src/ast/scopes.cc View 1 2 3 4 5 6 5 chunks +23 lines, -5 lines 4 comments Download
M src/parsing/parser.cc View 1 2 3 4 5 11 chunks +83 lines, -34 lines 1 comment Download
M src/parsing/pattern-rewriter.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M test/mjsunit/es6/block-conflicts.js View 1 chunk +0 lines, -3 lines 0 comments Download
M test/mjsunit/es6/block-conflicts-sloppy.js View 1 chunk +0 lines, -3 lines 0 comments Download
M test/mjsunit/es6/block-sloppy-function.js View 1 2 1 chunk +39 lines, -0 lines 0 comments Download
A test/mjsunit/es6/catch-parameter-redeclaration.js View 1 2 3 4 5 6 1 chunk +112 lines, -0 lines 0 comments Download
A test/mjsunit/es6/for-each-in-catch.js View 1 chunk +193 lines, -0 lines 0 comments Download
M test/test262/test262.status View 1 2 3 4 2 chunks +0 lines, -5 lines 0 comments Download

Messages

Total messages: 43 (17 generated)
bakkot
4 years, 5 months ago (2016-06-28 22:09:44 UTC) #3
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2109733003/1
4 years, 5 months ago (2016-06-29 18:31:29 UTC) #5
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_linux64_rel_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux64_rel_ng/builds/8274) v8_linux_dbg_ng on ...
4 years, 5 months ago (2016-06-29 18:34:26 UTC) #7
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2109733003/20001
4 years, 5 months ago (2016-06-29 19:17:53 UTC) #9
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_win_nosnap_shared_rel_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_win_nosnap_shared_rel_ng/builds/4264) v8_win_nosnap_shared_rel_ng_triggered on ...
4 years, 5 months ago (2016-06-29 19:35:53 UTC) #11
Dan Ehrenberg
https://codereview.chromium.org/2109733003/diff/1/src/parsing/parser.cc File src/parsing/parser.cc (right): https://codereview.chromium.org/2109733003/diff/1/src/parsing/parser.cc#newcode3643 src/parsing/parser.cc:3643: // special case for legacy for (var/const x =.... ...
4 years, 5 months ago (2016-06-29 20:24:32 UTC) #12
bakkot
https://codereview.chromium.org/2109733003/diff/1/src/parsing/parser.cc File src/parsing/parser.cc (right): https://codereview.chromium.org/2109733003/diff/1/src/parsing/parser.cc#newcode3643 src/parsing/parser.cc:3643: // special case for legacy for (var/const x =.... ...
4 years, 5 months ago (2016-06-29 21:10:14 UTC) #13
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2109733003/60001
4 years, 5 months ago (2016-06-29 21:10:27 UTC) #15
bakkot
This probably shouldn't be committed until after https://codereview.chromium.org/2110193002/, which touches some of the same code ...
4 years, 5 months ago (2016-06-29 21:12:35 UTC) #16
Dan Ehrenberg
lgtm Thanks for the cleanup; I trust you to do the rebase when appropriate.
4 years, 5 months ago (2016-06-29 21:37:48 UTC) #17
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 5 months ago (2016-06-29 21:37:56 UTC) #19
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2109733003/80001
4 years, 5 months ago (2016-06-30 17:20:01 UTC) #21
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_linux64_avx2_rel_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux64_avx2_rel_ng/builds/4253) v8_linux64_avx2_rel_ng_triggered on ...
4 years, 5 months ago (2016-06-30 17:39:37 UTC) #23
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2109733003/100001
4 years, 5 months ago (2016-06-30 20:52:26 UTC) #25
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 5 months ago (2016-06-30 21:17:43 UTC) #27
bakkot
Nontrivial changes since last lgtm (Adam's patch changed some semantics); PTAL.
4 years, 5 months ago (2016-06-30 21:32:00 UTC) #28
Dan Ehrenberg
lgtm Unfortunate, but makes sense. I wonder if it would've been OK to just use ...
4 years, 5 months ago (2016-06-30 22:11:18 UTC) #29
Dan Ehrenberg
By the way, any idea what's behind the failing Blink test http/tests/media/video-seek-to-middle.html ? I didn't ...
4 years, 5 months ago (2016-06-30 22:12:09 UTC) #30
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2109733003/100001
4 years, 5 months ago (2016-06-30 23:10:23 UTC) #32
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 5 months ago (2016-06-30 23:12:33 UTC) #34
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2109733003/100001
4 years, 5 months ago (2016-06-30 23:58:22 UTC) #36
commit-bot: I haz the power
Committed patchset #6 (id:100001)
4 years, 5 months ago (2016-07-01 00:00:48 UTC) #37
commit-bot: I haz the power
Patchset 6 (id:??) landed as https://crrev.com/2907c726b2bb5cf20b2bec639ca9e6a521585406 Cr-Commit-Position: refs/heads/master@{#37462}
4 years, 5 months ago (2016-07-01 00:01:43 UTC) #39
bakkot
A revert of this CL (patchset #6 id:100001) has been created in https://codereview.chromium.org/2112223002/ by bakkot@google.com. ...
4 years, 5 months ago (2016-07-01 04:21:34 UTC) #40
bakkot
Fixed the bug found by the fuzzer (was using the wrong index in a nested ...
4 years, 5 months ago (2016-07-01 18:58:52 UTC) #41
adamk
4 years, 5 months ago (2016-07-01 19:14:06 UTC) #43
Message was sent while issue was closed.
Thanks for the fix, but I've got some comments on other parts of the CL (sorry I
didn't take another pass on the original version).

https://codereview.chromium.org/2109733003/diff/120001/src/ast/scopes.cc
File src/ast/scopes.cc (right):

https://codereview.chromium.org/2109733003/diff/120001/src/ast/scopes.cc#newc...
src/ast/scopes.cc:613: Declaration* Scope::CheckLexDeclarationsConflictingWith(
Is this only called on block scopes? Can you add a DCHECK to that effect if it's
true?

https://codereview.chromium.org/2109733003/diff/120001/src/ast/scopes.cc#newc...
src/ast/scopes.cc:615: int length = names->length();
Nit: should be no need to hoist this.

https://codereview.chromium.org/2109733003/diff/120001/src/ast/scopes.cc#newc...
src/ast/scopes.cc:618: if (var != nullptr && IsLexicalVariableMode(var->mode()))
{
If my DCHECK suggestion above is correct, then can IsLexicalVariableMode ever be
false here?

https://codereview.chromium.org/2109733003/diff/120001/src/ast/scopes.cc#newc...
src/ast/scopes.cc:621: int decls_length = decls_.length();
Again, no need to hoist this out of the loop.

https://codereview.chromium.org/2109733003/diff/120001/src/ast/scopes.h
File src/ast/scopes.h (right):

https://codereview.chromium.org/2109733003/diff/120001/src/ast/scopes.h#newco...
src/ast/scopes.h:245: ZoneList<const AstRawString*>* names);
Style: given that this arg isn't mutated by the callee, it ought to be a
 const reference (that is, "const ZoneList<const AstRawString*>&").

https://codereview.chromium.org/2109733003/diff/120001/src/ast/scopes.h#newco...
src/ast/scopes.h:502: AstRawString* catch_variable_name() const {
this should return a "const AstRawString*", non-const AstRawStrings really
shouldn't exist (and only do because our hashmap is not typed enough).

https://codereview.chromium.org/2109733003/diff/120001/src/parsing/parser.cc
File src/parsing/parser.cc (right):

https://codereview.chromium.org/2109733003/diff/120001/src/parsing/parser.cc#...
src/parsing/parser.cc:3068: position == kNoSourcePosition
When does this hold?

Powered by Google App Engine
This is Rietveld 408576698