Firstly functions seem to be able to return strings or None, but if I try to return an integer I get "ViperTypeError: return expected 'object' but got 'int'". Secondly, to avoid compile time errors it seems necessary to cast function arguments to integers to perform bitwise operations on them (even though at runtime they would be passed as integers). This example yields at compile time "ViperTypeError: can't do binary op between 'object' and 'int'" .:
Code: Select all
@micropython.viper
def foo(num):
num <<= 1
return "4" if num == 4 else "not four"