RESOLVED FIXED 17027
Incorrect Function.toString behaviour with read/modify/write operators performed on negative numbers
https://bugs.webkit.org/show_bug.cgi?id=17027
Summary Incorrect Function.toString behaviour with read/modify/write operators perfor...
Oliver Hunt
Reported 2008-01-26 18:20:38 PST
Function.toString loses necessary parentheses when performing read/modify/write operations like >>>=, etc on *negative* numbers. eg. function f() { (-1) >>>= 1; } becomes function f() { -1 >>>= 1; }
Attachments
patch (11.79 KB, patch)
2008-01-26 20:05 PST, Darin Adler
oliver: review+
Darin Adler
Comment 1 2008-01-26 19:10:50 PST
I think the trick here is that in SourceStream::operator<<(double) we need to treat the "-" sign from the negative number as an operator, since that's how the lexer is going to treat it. Thus we need to check the precedence against the precedence of unary minus and set needParens in that case. This can all be fixed on the first line of that function where we initialize a needParens bool. Assigning to myself, assuming that if Ollie was going to fix this he'd have assigned it to himself.
Darin Adler
Comment 2 2008-01-26 19:22:28 PST
I found an even better way to fix this, by just returning the appropriate precedence. I'll make the test exhaustive now.
Oliver Hunt
Comment 3 2008-01-26 19:35:45 PST
That's basically what i was thinking :D However i decided to get food :D
Darin Adler
Comment 4 2008-01-26 20:05:26 PST
Oliver Hunt
Comment 5 2008-01-26 20:15:05 PST
Comment on attachment 18715 [details] patch r=m1, with the additional tests i requested on irc
Darin Adler
Comment 6 2008-01-26 20:23:15 PST
Committed revision 29815.
Note You need to log in before you can comment on or make changes to this bug.