← index #11667Issue #6177
Related · high · value 2.742
QUERY · ISSUE

ViperTypeError: div/mod not implemented for uint

openby massimosalaopened 2023-05-30updated 2024-09-04
enhancement

General topic, not related to a specific micro.

Viper is great for optimizing functions, like custom hashes, that only do calculations on integers... but

ViperTypeError: div/mod not implemented for uint

Is it possible to implement this?

CANDIDATE · ISSUE

Viper throws exception on math operations between uints

closedby peterhinchopened 2020-06-21updated 2020-06-26
py-core

The following fails with ViperTypeError: can't do binary op between 'uint' and 'uint'

@micropython.viper
def foo(x:uint) -> uint:
    return x + uint(9)  # Every operator I tried failed here

Tested on Pyboard D SF6W. Ref this forum thread.

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