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; }
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.
I found an even better way to fix this, by just returning the appropriate precedence. I'll make the test exhaustive now.
That's basically what i was thinking :D However i decided to get food :D
Created attachment 18715 [details] patch
Comment on attachment 18715 [details] patch r=m1, with the additional tests i requested on irc
Committed revision 29815.