Closed Bug 632027 Opened 13 years ago Closed 12 years ago

Reflect.parse: ArrayExpression elements that are SequenceExpressions are discarded

Categories

(Core :: JavaScript Engine, defect)

Other Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla17

People

(Reporter: jorendorff, Assigned: dherman)

Details

Attachments

(1 file)

js> Reflect.parse("[0, (1,2)]", {loc:0}).body[0].expression.elements
[{loc:null, type:"Literal", value:0}, ,]
Assignee: general → dherman
Attachment #653423 - Flags: review?(jorendorff)
Comment on attachment 653423 [details] [diff] [review]
fixes handling of array holes

Review of attachment 653423 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/jsreflect.cpp
@@ +2921,5 @@
>      if (!elts.reserve(pn->pn_count))
>          return false;
>  
>      for (ParseNode *next = pn->pn_head; next; next = next->pn_next) {
> +        /* Comma expressions can't occur inside patterns, so no need to test pn_count. */

Heh. Logic is good. Logic and a JS_ASSERT is better.

::: js/src/tests/js1_8_5/extensions/reflect-parse.js
@@ +333,5 @@
>  assertExpr("[,,,1,2,3,]", arrExpr([,,,lit(1),lit(2),lit(3),]));
>  assertExpr("[,,,1,2,3,,]", arrExpr([,,,lit(1),lit(2),lit(3),,]));
>  assertExpr("[,,,1,2,3,,,]", arrExpr([,,,lit(1),lit(2),lit(3),,,]));
>  assertExpr("[,,,,,]", arrExpr([,,,,,]));
> +assertExpr("[,,,,,]", arrExpr([null,null,null,null,null]));

You meant to remove the previous one, right?

In fact, shouldn't all these change to have nulls in the expected result?
Attachment #653423 - Flags: review?(jorendorff) → review+
https://hg.mozilla.org/mozilla-central/rev/67ff83142ba5
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla17
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: