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

Issue 6335010: Strict mode object literal validation (Closed)

Created:
9 years, 11 months ago by Martin Maly
Modified:
9 years, 7 months ago
CC:
v8-dev
Visibility:
Public.

Description

Strict mode object literal validation (Draft) * Detect duplicate data properties in strict mode * Detect conflict between 2 accessors of same kind or accessor and data property. BUG= TEST=test/mjsunit/strict-mode.js

Patch Set 1 #

Total comments: 16

Patch Set 2 : CR Feedback #

Patch Set 3 : Fix assert #

Total comments: 8

Patch Set 4 : CR feedback #

Unified diffs Side-by-side diffs Delta from patch set Stats (+187 lines, -0 lines) Patch
M src/messages.js View 1 chunk +3 lines, -0 lines 0 comments Download
M src/parser.cc View 1 2 3 5 chunks +135 lines, -0 lines 0 comments Download
M test/mjsunit/strict-mode.js View 1 2 3 1 chunk +49 lines, -0 lines 0 comments Download

Messages

Total messages: 9 (0 generated)
Martin Maly
Draft of object literal validation. Most of the checks are actually required even outside of ...
9 years, 11 months ago (2011-01-21 00:41:06 UTC) #1
Lasse Reichstein
LGTM if non-strict code in either Safari or Firefox already throw exceptions where we will ...
9 years, 11 months ago (2011-01-21 12:01:13 UTC) #2
MarkM
http://codereview.chromium.org/6335010/diff/1/src/parser.cc File src/parser.cc (right): http://codereview.chromium.org/6335010/diff/1/src/parser.cc#newcode3108 src/parser.cc:3108: // Data property conflicting with an accessor. On WebKit ...
9 years, 11 months ago (2011-01-21 17:37:55 UTC) #3
Martin Maly
Hi Lasse, thanks for reviewing the code for me. Please take another look. Thank you! ...
9 years, 11 months ago (2011-01-21 20:00:36 UTC) #4
Mads Ager (chromium)
The only places where this patch will throw exceptions where we didn't before is in ...
9 years, 11 months ago (2011-01-24 07:15:40 UTC) #5
Lasse Reichstein
True. The changes are only in cases that didn't exist in ES3, so it's not ...
9 years, 11 months ago (2011-01-24 07:57:01 UTC) #6
Martin Maly
Fixed both locations with this issue, added comment and more tests. http://codereview.chromium.org/6335010/diff/1/src/parser.cc File src/parser.cc (right): ...
9 years, 11 months ago (2011-01-24 18:09:08 UTC) #7
Lasse Reichstein
LGTM with comments addressed. http://codereview.chromium.org/6335010/diff/6002/src/ast.cc File src/ast.cc (right): http://codereview.chromium.org/6335010/diff/6002/src/ast.cc#newcode245 src/ast.cc:245: if (handle->ToArrayIndex(&index)) { I already ...
9 years, 11 months ago (2011-01-25 11:19:03 UTC) #8
Martin Maly
9 years, 11 months ago (2011-01-25 18:29:23 UTC) #9
Thanks, I addressed all the feedback.

Martin

http://codereview.chromium.org/6335010/diff/6002/src/ast.cc
File src/ast.cc (right):

http://codereview.chromium.org/6335010/diff/6002/src/ast.cc#newcode245
src/ast.cc:245: if (handle->ToArrayIndex(&index)) {
On 2011/01/25 11:19:03, Lasse Reichstein wrote:
> I already committed a patch for this case.
> During that I checked what happens, and this change isn't even sufficient. The
> ToArrayIndex function only works on numbers (Smi and HeapNumber), not strings.
> You need a second case inside the IsSymbol case to account for a string that
> represents an array index.

Thanks, I reverted this part of my change.

http://codereview.chromium.org/6335010/diff/6002/src/parser.cc
File src/parser.cc (right):

http://codereview.chromium.org/6335010/diff/6002/src/parser.cc#newcode3077
src/parser.cc:3077: if (handle->ToArrayIndex(&hash)) {
On 2011/01/25 11:19:03, Lasse Reichstein wrote:
> This still needs to handle array-index symbols.
> You can see the code in my change for ast.cc:
> http://codereview.chromium.org/6304016/
> 

Done.

http://codereview.chromium.org/6335010/diff/6002/test/mjsunit/strict-mode.js
File test/mjsunit/strict-mode.js (right):

http://codereview.chromium.org/6335010/diff/6002/test/mjsunit/strict-mode.js#...
test/mjsunit/strict-mode.js:125: 
On 2011/01/25 11:19:03, Lasse Reichstein wrote:
> For good measure, try with
>  var x = {123: 1, "0123": 2};
> 
>  var x = {123: 1,
> 123.00000000000000000000000000000000000000000000000000000000000000000001 : 2}
> 
> and 
> 
>  var x = {123: 1,
> "123.00000000000000000000000000000000000000000000000000000000000000000001" :
2}
> 
> The first shouldn't throw, the second should (it's the same number), and the
> third shouldn't.

Done.

http://codereview.chromium.org/6335010/diff/6002/test/mjsunit/strict-mode.js#...
test/mjsunit/strict-mode.js:125: 
On 2011/01/25 11:19:03, Lasse Reichstein wrote:
> Also try get/set properties using strings and numbers, e.g.:
> 
>  var x = {get 12(){}, get "12"(){}};
>  var x = {get foo(){}, get "foo"(){}};

Done.

Powered by Google App Engine
This is Rietveld 408576698