Zokrates / ZoKrates

A toolbox for zkSNARKs on Ethereum
https://zokrates.github.io
GNU Lesser General Public License v3.0
1.8k stars 360 forks source link

Mod operation fails on integer literals without type annotation #1332

Open gwdjkspnado opened 1 year ago

gwdjkspnado commented 1 year ago

Description

The % operator cannot be applied to integer constants without explicit type annotation.

Environment

Steps to Reproduce

Minimal code to reproduce the issue

def main() {
    u32 a = 2 % 1;
}

Compile with zokrates compile -i mod.zok, you would get the following error:

Compiling mod.zok

Compilation failed:

mod.zok:2:13
        Cannot apply `%` to {integer}, {integer}

If you explicitly specify the types of the integer constants, the error would be gone:

def main() {
    u32 a = 2u32 % 1u32;
}