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

Problem inferring generic types only used in returns #5929

Open
xunilrj opened this issue Apr 26, 2024 · 1 comment
Open

Problem inferring generic types only used in returns #5929

xunilrj opened this issue Apr 26, 2024 · 1 comment

Comments

@xunilrj
Copy link
Contributor

xunilrj commented Apr 26, 2024

predicate;

use std::inputs::input_predicate_data;

fn main() -> bool {
    let input: bool = input_predicate_data(0);
    input == true
}

This generates the following error:

          2936 | 
          2937 | pub trait AbiDecode {
          2938 |     fn abi_decode(ref mut buffer: BufferReader) -> Self;
               |        ^^^^^^^^^^ Internal compiler error: Method abi_decode_5 is a trait method dummy and was not properly replaced.
          Please file an issue on the repository and include the code that triggered this error.
          2939 | }

But the fully typed, and even the explicit version works fine

let input = input_predicate_data::<bool>(0);
@xunilrj xunilrj changed the title Problem with infering generic types only used in returns Problem inferring generic types only used in returns Apr 26, 2024
@xunilrj
Copy link
Contributor Author

xunilrj commented Apr 26, 2024

I think the issue is that at instantiate_function_application, we do not check for unbound generic arguments. Nor do we check for generic arguments never solved later.

This example compiles, and runs!

script;

fn input_predicate_data2<T> () -> bool {
    true
}

fn main() -> bool {
    let input: bool = input_predicate_data2();
    input == true
}

rustc gives the correct error:

error[E0282]: type annotations needed
 --> src/main.rs:6:23
  |
6 |     let input: bool = input_predicate_data2();
  |                       ^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `input_predicate_data2`
  |
help: consider specifying the generic argument
  |
6 |     let input: bool = input_predicate_data2::<T>();
  |                                            +++++

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant