Last Comment Bug 632030 - Reflect.parse doesn't handle doubly-declared variables correctly
: Reflect.parse doesn't handle doubly-declared variables correctly
reflect-parse fixed-in-tracemonkey
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: Other Branch
: All All
-- normal (vote)
: ---
Assigned To: Dave Herman [:dherman]
: Jason Orendorff [:jorendorff]
Depends on:
  Show dependency treegraph
Reported: 2011-02-07 07:33 PST by Jason Orendorff [:jorendorff]
Modified: 2011-06-27 11:40 PDT (History)
2 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

handle duplicate var bindings (!!declarator->pn_used) (4.77 KB, patch)
2011-06-07 08:14 PDT, Dave Herman [:dherman]
no flags Details | Diff | Splinter Review
fixed broken test case (10.05 KB, patch)
2011-06-22 21:39 PDT, Dave Herman [:dherman]
jorendorff: review+
Details | Diff | Splinter Review

Description User image Jason Orendorff [:jorendorff] 2011-02-07 07:33:48 PST
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(){}
    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.
Comment 1 User image Dave Herman [:dherman] 2011-06-07 08:14:44 PDT
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.

Comment 2 User image Dave Herman [:dherman] 2011-06-22 21:39:14 PDT
Created attachment 541284 [details] [diff] [review]
fixed broken test case

Oops, there was a busted test case.

Comment 3 User image Dave Herman [:dherman] 2011-06-23 09:32:58 PDT
Comment 4 User image Chris Leary [:cdleary] (not checking bugmail) 2011-06-27 11:40:29 PDT
cdleary-bot mozilla-central merge info:

Note You need to log in before you can comment on or make changes to this bug.