The default bug view has changed. See this FAQ.

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

RESOLVED FIXED

Status

()

Core
JavaScript Engine
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: jorendorff, Assigned: dherman)

Tracking

Other Branch
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

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

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

6 years ago
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.
(Assignee)

Updated

6 years ago
Whiteboard: reflect-parse
(Assignee)

Comment 1

6 years ago
Created attachment 537795 [details] [diff] [review]
handle duplicate var bindings (!!declarator->pn_used)

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)
(Assignee)

Comment 2

6 years ago
Created attachment 541284 [details] [diff] [review]
fixed broken test case

Oops, there was a busted test case.

Dave
Attachment #537795 - Attachment is obsolete: true
Attachment #541284 - Flags: review?(jorendorff)
Attachment #537795 - Flags: review?(jorendorff)
(Reporter)

Updated

6 years ago
Attachment #541284 - Flags: review?(jorendorff) → review+
(Assignee)

Comment 3

6 years ago
http://hg.mozilla.org/tracemonkey/rev/56ea7c0ebe16
Whiteboard: reflect-parse → reflect-parse fixed-in-tracemonkey
cdleary-bot mozilla-central merge info:
http://hg.mozilla.org/mozilla-central/rev/56ea7c0ebe16
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.