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

"Does not unify with trait method type" panic in comptime code #5428

Closed
jfecher opened this issue Jul 5, 2024 · 0 comments · Fixed by #5471
Closed

"Does not unify with trait method type" panic in comptime code #5428

jfecher opened this issue Jul 5, 2024 · 0 comments · Fixed by #5471
Labels
bug Something isn't working

Comments

@jfecher
Copy link
Contributor

jfecher commented Jul 5, 2024

Aim

fn main() {
    assert_false!();
}

comptime fn assert_false() -> Quoted {
    let first = quote { assert( };
    let second = quote { false); };
    first.append(second)
}

Expected Behavior

The program to run, and fail with an assert(false);

Bug

The application panicked (crashed).
Message:  internal error: entered unreachable code: Impl method type fn(Quoted, Quoted) -> Quoted does not unify with trait method type fn(Self, Self) -> Self during monomorphization
Location: compiler/noirc_frontend/src/monomorphization/mod.rs:1771

This is a bug. We may have already fixed this in newer versions of Nargo so try searching for similar issues at https://github.com/noir-lang/noir/issues/.
If there isn't an open issue for this bug, consider opening one at https://github.com/noir-lang/noir/issues/new?labels=bug&template=bug_report.yml
exit 101

To Reproduce

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

@jfecher jfecher added the bug Something isn't working label Jul 5, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Jul 5, 2024
github-merge-queue bot pushed a commit that referenced this issue Jul 8, 2024
# Description

## Problem\*

Working towards #5428

## Summary\*

Changes the panic in #5428 to an
error instead. The original error message was no longer appropriate
either since this was occurring in the interpreter rather than the
monomorphizer.

## Additional Context

This doesn't fix the issue, I just thought it'd be slightly nicer UX
going forward if we didn't panic here.

## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** 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.
github-merge-queue bot pushed a commit that referenced this issue Jul 12, 2024
…eter (#5471)

# Description

## Problem\*

Resolves #5428

## Summary\*

The interpreter was calling into `perform_impl_bindings` in more cases
than the monomorphizer.
Where the former calls into it for every trait impl method, the later
only calls into it for methods called from a `TraitMethodExpr` or
`ImplKind::TraitMethod` on an ident/operator.
It seemed more correct to call into this function in all cases so I
removed the bug by also replacing NamedGenerics in the trait itself with
bindable type variables.

## Additional Context

I've moved around some methods in `hir_def/types.rs` so that we don't
have 3 separate `impl Type {`s in the one file. The only two changes in
that file are the addition of
`replace_named_generics_with_type_variables` and the formatting change
for debugging NamedGenerics.

## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** 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.
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

1 participant