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

Issue 766663003: harmony-classes: Implement 'super(...)' call syntactic restriction. (Closed)

Created:
6 years ago by Dmitry Lomov (no reviews)
Modified:
6 years ago
CC:
v8-dev
Base URL:
https://chromium.googlesource.com/v8/v8.git@master
Project:
v8
Visibility:
Public.

Description

harmony-classes: Implement 'super(...)' call syntactic restriction. R=rossberg@chromium.org,arv@chromium.org BUG=v8:3330 LOG=N

Patch Set 1 #

Total comments: 10

Patch Set 2 : Patch for landing #

Total comments: 8
Unified diffs Side-by-side diffs Delta from patch set Stats (+591 lines, -51 lines) Patch
M BUILD.gn View 1 chunk +2 lines, -0 lines 0 comments Download
M src/ast.h View 1 1 chunk +3 lines, -2 lines 0 comments Download
M src/ast.cc View 1 chunk +9 lines, -2 lines 0 comments Download
A src/ast-this-access-visitor.h View 1 chunk +34 lines, -0 lines 1 comment Download
A src/ast-this-access-visitor.cc View 1 chunk +232 lines, -0 lines 2 comments Download
M src/compiler.cc View 1 4 chunks +77 lines, -1 line 1 comment Download
M src/messages.js View 1 1 chunk +2 lines, -0 lines 1 comment Download
M src/objects.h View 1 2 chunks +8 lines, -4 lines 0 comments Download
M src/objects-inl.h View 1 1 chunk +4 lines, -1 line 0 comments Download
M src/parser.cc View 1 2 chunks +3 lines, -3 lines 0 comments Download
M src/preparser.h View 3 chunks +7 lines, -5 lines 0 comments Download
M src/scopes.h View 4 chunks +26 lines, -8 lines 0 comments Download
M src/scopes.cc View 5 chunks +24 lines, -7 lines 1 comment Download
M test/cctest/test-parsing.cc View 4 chunks +28 lines, -18 lines 0 comments Download
M test/mjsunit/harmony/classes.js View 1 1 chunk +72 lines, -0 lines 2 comments Download
M test/mjsunit/harmony/super.js View 1 1 chunk +58 lines, -0 lines 0 comments Download
M tools/gyp/v8.gyp View 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 8 (1 generated)
Dmitry Lomov (no reviews)
PTAL
6 years ago (2014-11-27 17:53:37 UTC) #1
rossberg
LGTM with comments https://codereview.chromium.org/766663003/diff/1/src/compiler.cc File src/compiler.cc (right): https://codereview.chromium.org/766663003/diff/1/src/compiler.cc#newcode792 src/compiler.cc:792: Statement* stmt = body->at(super_call_index); Perhaps add ...
6 years ago (2014-11-27 19:04:40 UTC) #2
Dmitry Lomov (no reviews)
Comments addressed, landing https://codereview.chromium.org/766663003/diff/1/src/compiler.cc File src/compiler.cc (right): https://codereview.chromium.org/766663003/diff/1/src/compiler.cc#newcode792 src/compiler.cc:792: Statement* stmt = body->at(super_call_index); On 2014/11/27 ...
6 years ago (2014-11-27 19:41:57 UTC) #3
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/766663003/20001
6 years ago (2014-11-27 19:42:48 UTC) #5
commit-bot: I haz the power
Committed patchset #2 (id:20001)
6 years ago (2014-11-28 04:08:56 UTC) #6
arv (Not doing code reviews)
I thought the design we agreed upon was to allow statements and expressions that did ...
6 years ago (2014-12-01 15:14:07 UTC) #7
Dmitry Lomov (no reviews)
6 years ago (2014-12-01 15:37:03 UTC) #8
Message was sent while issue was closed.
I'll address other comments in a separate CL.

On 2014/12/01 15:14:07, arv wrote:
> I thought the design we agreed upon was to allow statements and expressions
that
> did not reference `this`?
> 
> I can change this to work in that fashion now that I am back.

The proper design would be to use a TDZ for this. I do not think we should
expand purely syntactic restriction to more than one statement
(e.g. what about
   if (1) { super(); }
or 
  { try { super(); } }
?


> 
>
https://codereview.chromium.org/766663003/diff/20001/src/ast-this-access-visi...
> File src/ast-this-access-visitor.cc (right):
> 
>
https://codereview.chromium.org/766663003/diff/20001/src/ast-this-access-visi...
> src/ast-this-access-visitor.cc:55: void ATAV::VisitBlock(Block* stmt) {
> VisitStatements(stmt->statements()); }
> I'm surprised that we don't have a base class that does all of this already?

Base recursive visitors are considered harmful. If you have to spell all cases
in all visitors, then you have to think about every visitor when you add an AST
node.
If there is a base recursive visitor, it is easy to forget to update some of
them.
> 
>
https://codereview.chromium.org/766663003/diff/20001/src/ast-this-access-visi...
> src/ast-this-access-visitor.cc:98: VisitIfNotNull(e->constructor());
> constructor cannot be null. If there isn't a user defined constructor we
create
> the default constructor.
> 
>
https://codereview.chromium.org/766663003/diff/20001/src/ast-this-access-visi...
> File src/ast-this-access-visitor.h (right):
> 
>
https://codereview.chromium.org/766663003/diff/20001/src/ast-this-access-visi...
> src/ast-this-access-visitor.h:33: }  // namespace v8::intrenal
> typo
> 
> https://codereview.chromium.org/766663003/diff/20001/src/compiler.cc
> File src/compiler.cc (right):
> 
>
https://codereview.chromium.org/766663003/diff/20001/src/compiler.cc#newcode772
> src/compiler.cc:772: MessageLocation location(info->script(),
> lit->start_position(),
> This position is not all that good.
> 
> https://codereview.chromium.org/766663003/diff/20001/src/messages.js
> File src/messages.js (right):
> 
>
https://codereview.chromium.org/766663003/diff/20001/src/messages.js#newcode186
> src/messages.js:186: super_constructor_call:        ["A 'super' constructor
call
> may only appear as the first statement of a function, and its arguments may
not
> access 'this'. Other forms are not yet supported."]
> I think you fixed the duplicate property in a follow up CL?

Yes. 
> 
> https://codereview.chromium.org/766663003/diff/20001/src/scopes.cc
> File src/scopes.cc (right):
> 
> https://codereview.chromium.org/766663003/diff/20001/src/scopes.cc#newcode905
> src/scopes.cc:905: if (scope_uses_super_constructor_call_) {
> Inconsistent use of {}
> 
>
https://codereview.chromium.org/766663003/diff/20001/test/mjsunit/harmony/cla...
> File test/mjsunit/harmony/classes.js (right):
> 
>
https://codereview.chromium.org/766663003/diff/20001/test/mjsunit/harmony/cla...
> test/mjsunit/harmony/classes.js:786: var y;
> Why should this throw? I thought the design we agreed upon was to allow
> statements and expressions that did not reference `this`?
> 
>
https://codereview.chromium.org/766663003/diff/20001/test/mjsunit/harmony/cla...
> test/mjsunit/harmony/classes.js:851: }());
> Can you add a test for `super.method()` too?
> 
> class C extends B {
>   constructor() {
>     super.method();
>     super();
>   }
> }

Powered by Google App Engine
This is Rietveld 408576698