Bug 17020

Summary: Function.toString does not parenthesise numbers for the bracket accessor
Product: WebKit Reporter: Oliver Hunt <oliver>
Component: JavaScriptCoreAssignee: Oliver Hunt <oliver>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, jruderman
Priority: P2 Keywords: HasReduction
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.4   
Bug Depends on:    
Bug Blocks: 13638    
Attachments:
Description Flags
Fixeration
darin: review+
updated patch
none
Updated fix mjs: review+

Description Oliver Hunt 2008-01-26 04:45:33 PST
In the example
function f() {
    (-1)[0];
}

f.toString() produces:
function f() {
    -1[0];
}

which is invalid JS
Comment 1 Oliver Hunt 2008-01-26 05:36:39 PST
Hmm, it would appear we get it wrong for all of the bracket nodes..
Comment 2 Oliver Hunt 2008-01-26 05:44:40 PST
Created attachment 18707 [details]
Fixeration
Comment 3 Darin Adler 2008-01-26 08:15:01 PST
Comment on attachment 18707 [details]
Fixeration

r=me
Comment 4 Sam Weinig 2008-01-26 11:23:03 PST
Created attachment 18710 [details]
updated patch

Since I broke Ollie's patch with a little cleanup, I went ahead and updated this patch to work with the new code.
Comment 5 Oliver Hunt 2008-01-26 17:03:26 PST
Created attachment 18713 [details]
Updated fix

This is a minor update to the prior patch to ensure "new (1)()" will work
Comment 6 Maciej Stachowiak 2008-01-26 18:12:51 PST
Comment on attachment 18713 [details]
Updated fix

r=me
Comment 7 Oliver Hunt 2008-01-26 18:17:45 PST
Fixed in r29813