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

"error[E0308]: mismatched types" when providing a default value for a f64 field #1161

Closed
ClementNerma opened this issue Dec 5, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@ClementNerma
Copy link

I have the following code:

#[derive(InputObject)]
pub struct FeedParams {
    #[graphql(default = 80.0)]
    min_rating: f64,

    #[graphql(default = 50)]
    max_items: usize,
}

Which results in the following compilation error:

error[E0308]: mismatched types
  --> src/library/feed.rs:24:10
   |
24 | #[derive(InputObject)]
   |          ^^^^^^^^^^^ expected `f64`, found enum `Result`
   |
   = note: expected type `f64`
              found enum `Result<_, _>`
   = note: this error originates in the derive macro `InputObject` (in Nightly builds, run with -Z macro-backtrace for more info)

I'm not quite sure what the problem is, if I change the min_rating field's type to something like u8 (and remove the .0 in the default value) it works fine.

@ClementNerma ClementNerma added the bug Something isn't working label Dec 5, 2022
@sunli829
Copy link
Collaborator

sunli829 commented Dec 7, 2022

Fixed in v5.0.3

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
None yet
Development

No branches or pull requests

2 participants