noir-lang / noir

Noir is a domain specific language for zero knowledge proofs
https://noir-lang.org
Apache License 2.0
821 stars 177 forks source link

Non-comptime local functions silently fail in a `comptime` context #5333

Closed jfecher closed 4 days ago

jfecher commented 5 days ago

Aim

Calling a non-comptime function in the same crate from within a comptime block:

fn main() {
    comptime { foo(); }
}

fn foo() {
    println("foo!");
}

Expected Behavior

An error since non-comptime functions in the same crate cannot be called from comptime contexts. This is because comptime items are elaborated before all non-comptime items.

Bug

The comptime interpreter will silently see only an empty block as the definition of foo and nothing will be printed out.

To Reproduce

1. 2. 3. 4.

Project Impact

None

Impact Context

No response

Workaround

None

Workaround Description

No response

Additional Context

No response

Installation Method

None

Nargo Version

No response

NoirJS Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response