QUERY · ISSUE
Minor Viper Flaw: Misleading error message
Accessing an undefined variable in Python and Micropython:
def quot(a:int, b:int) -> int:
return c//b
results in NameError: name 'c' isn't defined during execution.
Above function with @micropython.viper results in ViperTypeError: return expected 'int' but got 'object'during compilation.
Just now I realize that viper has to assume that c is some global python object. Which means the error message is correct. But it is misleading.
An addition like name 'c' isn't defined while compiling would be helpful imho.
CANDIDATE · ISSUE
esp8266: cannot have both a native and a viper function, MemoryError reported
bugport-esp8266
The following code should reproduce the issue:
@micropython.native
def f_nat(x):
return x+1
@micropython.viper
def f_vip(x: int) -> int:
return x+1
print('native:', f_nat(2), 'viper', f_vip(2))
reports:
MemoryError: memory allocation failed, allocating 100 bytes for native code
instead of
native: 3 viper 3 on other platforms.
But both functions consume less than 500 bytes each.