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

fix: Error when a local function is called in a comptime context #5334

Closed jfecher closed 4 days ago

jfecher commented 5 days ago

Description

Problem*

Resolves https://github.com/noir-lang/noir/issues/5333

Summary*

Issues an error when a non-comptime function in the same crate is called from a comptime context:

error: `id` cannot be called in a `comptime` context here
  ┌─ /.../non_comptime_local_fn_call/src/main.nr:3:18
  │
3 │         let _a = id(3);
  │                  ----- This function must be `comptime` or in a separate crate to be called
  │

Additional Context

This limitation is because all comptime items are elaborated before non-comptime items within a crate.

Documentation*

Check one:

PR Checklist*