Skip to content

Comptime division by zero returns zero #8842

@aakoshh

Description

@aakoshh

Aim

Discovered by the comptime_vs_brillig fuzz target.

The following program behaves differently in comptime and Brillig:

fn main() -> pub Field {
    comptime {
        let b: u32 = 0;
        (b as Field) / (b as Field)
    }
}

vs

fn main() -> pub Field {
        let b: u32 = 0;
        (b as Field) / (b as Field)
}

Expected Behavior

The comptime program should fail the same way as Brillig.

Bug

cargo run -q -p nargo_cli -- execute --silence-warnings
[fuzz_testing] Circuit witness successfully solved
[fuzz_testing] Witness saved to target/fuzz_testing.gz
[fuzz_testing] Circuit output: Field(0)

In Brillig:

cargo run -q -p nargo_cli -- execute --silence-warnings
error: Failed constraint
  ┌─ src/main.nr:3:5

3 │     (b as Field) / (b as Field)
  │     ---------------------------

  = Call stack:
    1. src/main.nr:3:5

Failed to solve program: 'Cannot satisfy constraint'

To Reproduce

See above

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

None

Blocker Context

No response

Nargo Version

nargo version = 1.0.0-beta.6 noirc version = 1.0.0-beta.6+8f838fd807c534aeb2944d4b6bb9ab13d3c3a9ae (git version hash: 0fb26fe, is dirty: true)

NoirJS Version

No response

Proving Backend Tooling & Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions