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

Improve error message when type cannot be resolved #877

Open
nilehmann opened this issue Nov 7, 2024 · 0 comments
Open

Improve error message when type cannot be resolved #877

nilehmann opened this issue Nov 7, 2024 · 0 comments
Labels
error-messages Better error messages good first issue Good for newcomers

Comments

@nilehmann
Copy link
Member

nilehmann commented Nov 7, 2024

Consider the following

#[flux::opaque]
#[flux::refined_by(b : bitvec <8>)]
pub struct BV8(u8);

impl BitAnd for BV8 {
    type Output = BV8;
    
    #[flux::trusted]
    #[flux::sig(fn(BV8 [@b1], BV8 [@b2]) -> bv_and(b1, b2))]
    fn bitand(self, rhs: BV8) -> BV8 { BV8(self.0 & rhs.0) }
}

It currently fails with

error[E0999]: cannot resolve `bv_and`
  --> attic/playground.rs:11:45
   |
11 |     #[flux::sig(fn(BV8 [@b1], BV8 [@b2]) -> bv_and(b1, b2))]
   |                                             ^^^^^^^^^^^^^^
   |
   = help: flux can only resolve a path if it is present in the definition being refined

bv_and is parsed as a type, but the error doesn't mention type anywhere. The help: is also not true since we implemented the global resolver so it should be removed.

We should give an error similar to what rustc gives

error[E0999]: cannot resolve type `bv_and` in this scope
  --> attic/playground.rs:11:45
   |
11 |     #[flux::sig(fn(BV8 [@b1], BV8 [@b2]) -> bv_and(b1, b2))]
   |                                             ^^^^^^^^^^^^^^
   |                                             not found in this scope
@nilehmann nilehmann added good first issue Good for newcomers error-messages Better error messages labels Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error-messages Better error messages good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant