Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
LogvinovLeon opened this issue Mar 15, 2024 · 2 comments · Fixed by #4570
Closed

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

LogvinovLeon opened this issue Mar 15, 2024 · 2 comments · Fixed by #4570
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@LogvinovLeon
Copy link
Contributor

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 LogvinovLeon added the bug Something isn't working label Mar 15, 2024
@TomAFrench
Copy link
Member

TomAFrench commented Mar 15, 2024

Thanks for highlighting this!

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

// Check that we are not passing a slice from an unconstrained runtime to a constrained runtime
if is_current_func_constrained
&& is_unconstrained_call
&& return_type.contains_slice()
{
self.errors.push(TypeCheckError::UnconstrainedSliceReturnToConstrained {
span: self.interner.expr_span(expr_id),
});
return Type::Error;
}

@TomAFrench TomAFrench added the good first issue Good for newcomers label Mar 15, 2024
@jfecher
Copy link
Contributor

jfecher commented Mar 15, 2024

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

github-merge-queue bot pushed a commit that referenced this issue Mar 18, 2024
…onstrained to constrained functions (#4570)

# Description
Added compiler errors for when a oracle or reference is passed from a
unconstrained to a constrained function.

## Problem\*
Currently the compiler panics when you pass a reference or an oracle
from a unconstrained to constrained function.

Resolves #4565

Closes 4565

## Summary\*
A compiler error has been added for each condition with an appropriate
message to aid the user.

## Documentation\*

Check one:
- [X ] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [ X] I have tested the changes locally.
- [ X] I have formatted the changes with
[Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.

---------

Co-authored-by: Maxim Vezenov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Archived in project
3 participants