Skip to content

Improve error message when passing in the storage keyword as a type into a function #1946

@Braqzen

Description

@Braqzen

Reproduce

contract;

storage {
    var: u64,
}

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

impl MyContract for Contract {
    fn test_function(s: storage) -> bool {
        let mut s = s;
        s.var = s.var + 1;
        true
    }
}

Error should state something similar to "storage" cannot be used as a type / Cannot pass in "storage" as a type into a function.

Screenshot

1

cc @FuelLabs/sway-compiler

Metadata

Metadata

Assignees

No one assigned

    Labels

    P: criticalShould be looked at before anything elsebugSomething isn't workingcompiler: frontendEverything to do with type checking, control flow analysis, and everything between parsing and IRgenduplicateThis issue or pull request already existsteam:compilerCompiler Team

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions