|
|
|
The question is should we silently accept unsigned integers?
Ehm... What do you mean 'silently accept'? Binary shift on uisigned integers/longs should be fine and supported. The current problem is that EmitBitwiseOperator determines resulting type and converts both, left and right operands to that type, which appears to be incorrect: right operator to shl and shr should be int (or could it be byte/short as well? I couldn't tempt csc into emitting anything other than i4 as right operand no matter how hard I tried). My fix practically just makes EmitBitwiseOperator convert right operand to i4 (and not i8, u8 and anything else), while still correctly converting left operand to ExpressionType.
Hi, I tried some tests with << and >> on various types, and it seems that with my patch nothing is changed much except that this bug gets fixed. For example uint << object produces an error, and uint << bool works the same way as in 0.7.6.2188 (didn't try latest trunk yet). However, while testing I stumbled upon something strange. The code:
uint a = 3456 It prints 3456, both before and after my patch (and looking at IL it seems to be correct, so maybe it is .NET bug after all). And this code: uint a = 3456 It prints 0 with Still don't understand what did you mean by silently accepting unsigned integers. Is there anything else I'd need to increase chance this bug gets fixed in trunk? I meant 'should boo behave like c# for the program below'?
using System; class Program } shift.cs(9,12): error CS0019: Operator '<<' cannot be applied to operands of type 'uint' and 'uint' |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Does anyone know about any possible side effects of this change?
(OpCodes.Shl seems to be used for integer types only, so there shouldn't be any)