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

Issue 1307223002: [es6] fix nested object literals with computed property names (Closed)

Created:
5 years, 4 months ago by caitp (gmail)
Modified:
5 years, 4 months ago
Reviewers:
wingo, adamk, rossberg
CC:
v8-dev
Base URL:
https://chromium.googlesource.com/v8/v8.git@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

[es6] fix nested object literals with computed property names Now, if a literal contains computed properties, it is non-simple and must be build with the runtime. This ensures the correct behaviour. BUG=v8:4387 LOG=N R=adamk, rossberg, wingo

Patch Set 1 #

Total comments: 2

Patch Set 2 : move detection of computed property names into accessor #

Patch Set 3 : Rename accessor to something that makes more sense #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+17 lines, -1 line) Patch
M src/ast.h View 1 2 1 chunk +4 lines, -0 lines 3 comments Download
M src/ast.cc View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M test/mjsunit/es6/computed-property-names.js View 1 chunk +11 lines, -0 lines 0 comments Download

Messages

Total messages: 11 (0 generated)
caitp (gmail)
PTAL --- this is working locally. I've not tested with computed properties in classes (it ...
5 years, 4 months ago (2015-08-24 15:56:27 UTC) #1
caitp (gmail)
On 2015/08/24 15:56:27, caitp wrote: > PTAL --- this is working locally. > > I've ...
5 years, 4 months ago (2015-08-24 16:02:15 UTC) #2
wingo
https://codereview.chromium.org/1307223002/diff/1/src/ast.cc File src/ast.cc (right): https://codereview.chromium.org/1307223002/diff/1/src/ast.cc#newcode437 src/ast.cc:437: bool is_simple = boilerplate_properties_ != 0 || properties()->length() == ...
5 years, 4 months ago (2015-08-24 16:04:40 UTC) #3
caitp (gmail)
https://codereview.chromium.org/1307223002/diff/1/src/ast.cc File src/ast.cc (right): https://codereview.chromium.org/1307223002/diff/1/src/ast.cc#newcode437 src/ast.cc:437: bool is_simple = boilerplate_properties_ != 0 || properties()->length() == ...
5 years, 4 months ago (2015-08-24 16:08:27 UTC) #4
wingo
lgtm
5 years, 4 months ago (2015-08-24 16:30:45 UTC) #5
adamk
https://codereview.chromium.org/1307223002/diff/40001/src/ast.h File src/ast.h (right): https://codereview.chromium.org/1307223002/diff/40001/src/ast.h#newcode1493 src/ast.h:1493: return boilerplate_properties_ == 0 && properties_->length() > 0; I ...
5 years, 4 months ago (2015-08-24 18:00:53 UTC) #6
adamk
https://codereview.chromium.org/1307223002/diff/40001/src/ast.h File src/ast.h (right): https://codereview.chromium.org/1307223002/diff/40001/src/ast.h#newcode1493 src/ast.h:1493: return boilerplate_properties_ == 0 && properties_->length() > 0; On ...
5 years, 4 months ago (2015-08-24 18:14:29 UTC) #7
adamk
https://codereview.chromium.org/1307223002/diff/40001/src/ast.h File src/ast.h (right): https://codereview.chromium.org/1307223002/diff/40001/src/ast.h#newcode1493 src/ast.h:1493: return boilerplate_properties_ == 0 && properties_->length() > 0; On ...
5 years, 4 months ago (2015-08-24 18:16:37 UTC) #8
caitp (gmail)
On 2015/08/24 18:14:29, adamk wrote: > https://codereview.chromium.org/1307223002/diff/40001/src/ast.h > File src/ast.h (right): > > https://codereview.chromium.org/1307223002/diff/40001/src/ast.h#newcode1493 > ...
5 years, 4 months ago (2015-08-24 18:17:17 UTC) #9
caitp (gmail)
On 2015/08/24 18:17:17, caitp wrote: > On 2015/08/24 18:14:29, adamk wrote: > > https://codereview.chromium.org/1307223002/diff/40001/src/ast.h > ...
5 years, 4 months ago (2015-08-24 18:29:50 UTC) #10
adamk
5 years, 4 months ago (2015-08-24 19:07:13 UTC) #11
On 2015/08/24 18:29:50, caitp wrote:
> On 2015/08/24 18:17:17, caitp wrote:
> > On 2015/08/24 18:14:29, adamk wrote:
> > > https://codereview.chromium.org/1307223002/diff/40001/src/ast.h
> > > File src/ast.h (right):
> > > 
> > >
https://codereview.chromium.org/1307223002/diff/40001/src/ast.h#newcode1493
> > > src/ast.h:1493: return boilerplate_properties_ == 0 &&
properties_->length()
> >
> > > 0;
> > > On 2015/08/24 18:00:53, adamk wrote:
> > > > I don't think the LHS of this expression is correct: it only works for
> > object
> > > > literals whose first property has a computed name. See the way the
> > > > number_of_boilerplate_properties is accumulated in ParseObjectLiteral():
> it
> > > only
> > > > stops counting up after it hits the first computed name. I suspect test
> > cases
> > > > where the first property is non-computed will keep failing with this
> patch.
> > > 
> > > Hmm, local testing suggests I'm wrong about this failing, so I'm not
totally
> > > sure what's going on.
> > 
> > Out for a bit, but I'll add more tests like this later. My reading of the
> parts
> > code is that if the has_computed_properties or whatever flag is set, it sets
> > boilerplate properties to 0. I'll add more tests in a bit
> 
> So you're saying it does fail that way in some cases?

Yes. For example:

out/Release/d8 -e "print(JSON.stringify([{name: 'ivan', [42]: 42 }]))"

still prints:

[{"name":"ivan"}]

with this patch applied.

Powered by Google App Engine
This is Rietveld 408576698