Bug 17020 - Function.toString does not parenthesise numbers for the bracket accessor
Summary: Function.toString does not parenthesise numbers for the bracket accessor
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Oliver Hunt
URL:
Keywords: HasReduction
Depends on:
Blocks: 13638
  Show dependency treegraph
 
Reported: 2008-01-26 04:45 PST by Oliver Hunt
Modified: 2008-02-11 17:02 PST (History)
2 users (show)

See Also:


Attachments
Fixeration (7.82 KB, patch)
2008-01-26 05:44 PST, Oliver Hunt
darin: review+
Details | Formatted Diff | Diff
updated patch (5.97 KB, patch)
2008-01-26 11:23 PST, Sam Weinig
no flags Details | Formatted Diff | Diff
Updated fix (6.38 KB, patch)
2008-01-26 17:03 PST, Oliver Hunt
mjs: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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