Closed Bug 632030 Opened 12 years ago Closed 11 years ago

Reflect.parse doesn't handle doubly-declared variables correctly

Categories

(Core :: JavaScript Engine, defect)

Other Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jorendorff, Assigned: dherman)

Details

(Whiteboard: reflect-parse fixed-in-tracemonkey)

Attachments

(1 file, 1 obsolete file)

Given this program:
    function g(x) { var x; }
Reflect.parse sees this:
    function g(x) { var x = x; }

This is a little strange, but I don't think the difference is observable.

But Reflect.parse also gives the same output for
    f.p = 1; var f; f.p; function f(){}
and
    f.p = 1; var f = function f(){}; f.p; function f(){}
and these are definitely two different programs. The first evals to 1; the
second evals to undefined.
Whiteboard: reflect-parse
Another undocumented case in jsparse.h. :)

When a var declaration is a duplicate of a funarg or function declaration, its TOK_NAME declarator node has pn_used set, and the pn_lexdef variant of the union is supposed to be used, not the pn_expr variant.

This patch fixes the missing case in jsreflect, adds the information to the jsparse.h documentation comment, and adds test cases for this bug.

Dave
Assignee: general → dherman
Attachment #537795 - Flags: review?(jorendorff)
Oops, there was a busted test case.

Dave
Attachment #537795 - Attachment is obsolete: true
Attachment #541284 - Flags: review?(jorendorff)
Attachment #537795 - Flags: review?(jorendorff)
Attachment #541284 - Flags: review?(jorendorff) → review+
http://hg.mozilla.org/tracemonkey/rev/56ea7c0ebe16
Whiteboard: reflect-parse → reflect-parse fixed-in-tracemonkey
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.