← index #7808Issue #1847
Off-topic · high · value 0.697
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

viper: ViperTypeError: can't do binary op between 'uint' and 'uint'

closedby peterhinchopened 2016-02-15updated 2020-06-26

The following produces the above error at compile time (only with uints - compiles and runs with int)

@micropython.viper
def foo(arg1: uint, arg2: uint) -> uint:
    return arg1 + arg2

MicroPython v1.6-35-ge372e83 on 2016-02-11; PYBv1.0 with STM32F405RG

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