← index #7808Issue #13387
Off-topic · high · value 0.649
QUERY · ISSUE

Minor Viper Flaw: Misleading error message

openby RaulKompassopened 2021-09-16updated 2021-09-20

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

closedby rkompassopened 2024-01-08updated 2024-01-10
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.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied