Skip to content

Bug: Invalid warnings when using namespaces and multiple ABIs #7442

@bitzoic

Description

@bitzoic

If you have 2 namespaces, the namespace will only check the first ABI in a contract. If the storage variable is used in a second ABI within the contract, the compiler will still issue a warning.

Secondly, storage variables that are not used in a second namespace does not issue warnings.

Minimal Repro:

contract;

storage {
    v1 {
        my_storage_var: u64 = 0, // This is warned as not used but is used in MySecondABI
    },
    v2 {
        my_storage_var: u64 = 0, // This is not used at all and never receives a warning
    },
}

abi MyFirstABI {
    fn test_function_1() -> bool;
}

abi MySecondABI {
    #[storage(read, write)]
    fn test_function_2() -> bool;
}

// This abi does not use storage.
impl MyFirstABI for Contract {
    fn test_function_1() -> bool {
        true
    }
}

// This abi uses storage
impl MySecondABI for Contract {
    #[storage(read, write)]
    fn test_function_2() -> bool {
        let my_var = storage::v1.my_storage_var.read();
        log(my_var);
        storage::v1.my_storage_var.write(1);
        true
    }
}
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    DCAEverything to do with Dead Code AnalysisbugSomething isn't workingcompilerGeneral compiler. Should eventually become more specific as the issue is triagedcompiler: uiMostly compiler messagesteam:compilerCompiler Team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions