noir icon indicating copy to clipboard operation
noir copied to clipboard

Compiler should not panic when an oracle is called from constrained method

Open LogvinovLeon opened this issue 11 months ago • 2 comments

Aim

Get compilation error instead of compiler panic

Expected Behavior

compilation error

Bug

The application panicked (crashed). Message: internal error: entered unreachable code: All oracle methods should be wrapped in an unconstrained fn Location: compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs:615

To Reproduce

  1. Call an oracle function directly from constrained code

Project Impact

None

Impact Context

No response

Workaround

Yes

Workaround Description

Just don't do it ;)

Additional Context

No response

Installation Method

None

Nargo Version

noirc version = 0.25.0+3ad88696ab63d8b1838b4ca7e9a3a97f823ca976

NoirJS Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

LogvinovLeon avatar Mar 15 '24 15:03 LogvinovLeon

Thanks for highlighting this!

This can be done with similar logic used to prevent passing slices to unconstrained functions from constrained ones.

https://github.com/noir-lang/noir/blob/a8b7cdb8a3698bc8923b6fa8714deebb8bf3923f/compiler/noirc_frontend/src/hir/type_check/expr.rs#L186-L195

TomAFrench avatar Mar 15 '24 15:03 TomAFrench

@TomAFrench we should probably generalize that check to error for all types that are invalid to pass from unconstrained to constrained. Such as references.

jfecher avatar Mar 15 '24 15:03 jfecher