- Code: Select all
def main is shared
b = 255u8
b = 255u8 & 31u8 #OK
assert b == 31_u8
assert b.getType is Byte
b1 = 255u8
b1 &= 31u8 #0x1f_u8 # OK
assert b1 == 31u8
b1 = 255u8
b1 = b1 & 31u8 # compile error: cannot implicitly convert int to byte (c#)
print b1
assert b1 == 31u8
b1 = 255u8
b2 = 31u8 #0x1fu8
b1 = b2 & b1 # compile error: cannot implicitly convert int to byte (c#)
print b
assert b1 == 31u8
Lines marked with 'compile error comment emit a compile error from the c# compiler phase. The earlier lines doing the same thing ( marked #OK) compiles OK.
using int32 ( defaults - no u?? on literals) compiles fine.
if I cast the # compile error lines
- Code: Select all
b1 = (b1 & 31u8) to uint8
get a warning from cobra but compiles and runs fine.