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

Frontend: panic on default traits parameters #310

Closed
W95Psp opened this issue Oct 30, 2023 · 4 comments · Fixed by #947
Closed

Frontend: panic on default traits parameters #310

W95Psp opened this issue Oct 30, 2023 · 4 comments · Fixed by #947
Assignees
Labels
frontend Issue in the Rust to JSON translation

Comments

@W95Psp
Copy link
Collaborator

W95Psp commented Oct 30, 2023

The following piece of code:

trait Foo: Bar {
    type U;
}
trait Bar<T = <Self as Foo>::U> {}

Open this code snippet in the playground

Yields a panic in the frontend.

@W95Psp W95Psp changed the title Defaults traits bounds Frontend: panic on default traits bounds Oct 31, 2023
@W95Psp W95Psp self-assigned this Oct 31, 2023
@W95Psp W95Psp added the frontend Issue in the Rust to JSON translation label Oct 31, 2023
@W95Psp W95Psp added the bug Something isn't working label Jul 8, 2024
@W95Psp
Copy link
Collaborator Author

W95Psp commented Jul 8, 2024

This is still the case, with:

error[E9999]: Cannot handle error `Unimplemented` selecting `Binder { value: <Self as Foo>, bound_vars: [] }`
 --> literals/src/lib.rs:4:1
  |
4 | trait Bar<T = <Self as Foo>::U> {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: ⚠️ This is a bug in Hax's frontend.
          Please report this error to https://github.com/hacspec/hax/issues with some context (e.g. the current crate)!

@W95Psp
Copy link
Collaborator Author

W95Psp commented Oct 2, 2024

This was silenced as a warning by PR #898, but this is still an issue.

@Nadrieril Nadrieril changed the title Frontend: panic on default traits bounds Frontend: panic on default traits parameters Oct 2, 2024
@Nadrieril
Copy link
Collaborator

Rustc always gives us the right parameters when referring to a trait, right? Can we ignore the default parameters entirely?

@W95Psp
Copy link
Collaborator Author

W95Psp commented Oct 2, 2024

Ah, that's true, you're right, we don't do anything with this information, and rust always inline parameters at use site.

So dropping default parameters would be an easy fix! I guess I can push a PR that disables that with a comment: in an ideal world I'd like that info to be exported since we "have" it, but we don't have unlimited time 😅

@W95Psp W95Psp removed the bug Something isn't working label Oct 2, 2024
W95Psp added a commit that referenced this issue Oct 2, 2024
This PR disable default parameters on traits, both in the engine and
in the exporter, following the conversation in #310.

Explanation (quoting my comment in code):

> On use site, Rust always give us all the generic
> parameters, no matter the defaultness. This information is
> thus not so useful. At the same time, as discussed in
> #310, extracting this
> default type causes failures when querying Rust for trait
> resolution. We thus decided to disable this feature. If
> this default type information is useful to you, please
> open an issue on https://github.com/hacspec/hax.

Fixes #310
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend Issue in the Rust to JSON translation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants