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

Unable to find associated methods for types in some cases #1747

Closed
emilyaherbert opened this issue May 28, 2022 · 5 comments · Fixed by #1958
Closed

Unable to find associated methods for types in some cases #1747

emilyaherbert opened this issue May 28, 2022 · 5 comments · Fixed by #1958
Assignees
Labels
bug Something isn't working compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen

Comments

@emilyaherbert
Copy link
Contributor

Potentially related: a recurring issue where unwrap() can't be found when trying to call result.unwrap(). Turns out this can be worked around by explicitly annotating the type:

let sender: Result<Sender, AuthError> = msg_sender(); // if you remove `: Result<Sender, AuthError>` this doesn't work!
sender.unwrap();

Originally posted by @adlerjohn in #1734 (comment)

@adlerjohn adlerjohn added bug Something isn't working compiler General compiler. Should eventually become more specific as the issue is triaged labels May 28, 2022
@adlerjohn adlerjohn moved this to Todo in Fuel Network May 28, 2022
@mohammadfawaz mohammadfawaz added compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen and removed compiler General compiler. Should eventually become more specific as the issue is triaged labels May 29, 2022
@emilyaherbert emilyaherbert self-assigned this Jun 9, 2022
@mohammadfawaz
Copy link
Contributor

Dup of #1628

Repository owner moved this from Todo to Done in Fuel Network Jun 9, 2022
@emilyaherbert
Copy link
Contributor Author

Reopening because it is actually not a direct dupe of #1628, just related to it.

@emilyaherbert emilyaherbert reopened this Jun 14, 2022
Repository owner moved this from Done to In Progress in Fuel Network Jun 14, 2022
@bitzoic
Copy link
Member

bitzoic commented Jun 14, 2022

I am getting method not found for the following snippet of code:

struct MyStruct {
    int_option: Option<u64>
}

storage {
    stored_struct: MyStruct,
}

abi MyContract {
    fn test_function() -> bool;
}

impl MyContract for Contract {
    fn test_function() -> bool {

        let stored_struct = storage.stored_struct;
        let stored_option_in_struct = stored_struct.int_option;
        require(stored_option_in_struct.is_some(), "Error");

        true
    }
}

stored_option_error

@Braqzen
Copy link
Contributor

Braqzen commented Jun 19, 2022

I am getting method not found for the following snippet of code:

struct MyStruct {
    int_option: Option<u64>
}

storage {
    stored_struct: MyStruct,
}

abi MyContract {
    fn test_function() -> bool;
}

impl MyContract for Contract {
    fn test_function() -> bool {

        let stored_struct = storage.stored_struct;
        let stored_option_in_struct = stored_struct.int_option;
        require(stored_option_in_struct.is_some(), "Error");

        true
    }
}

stored_option_error

use std::option::*;

@emilyaherbert
Copy link
Contributor Author

@Braqzen the bug here was coming from a different problem---i.e. manually annotating the type made this example compile. There is a PR up right now that fixes this though.

Repository owner moved this from In Progress to Done in Fuel Network Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants