Skip to content

Fix issues in self impl Contract implementation #7581

@ironcev

Description

@ironcev

#7580 fixes several issues related to self impl Contracts, but not all of them. This is the list of remaining known issues in the impl Contract implementation.

  • Using pub keyword on fn and const items must emit the "Unnecessary visibility qualifier, pub is implied here." error.

  • impl Contract must be allowed only in contract project types. Currently we can have, e.g.,

    library;
    impl Contract { }

    This seams to be a general issue. Having impl Abi for Contract { ... } in non-contract projects currently does not render errors.

  • Clashing of the generated ABI name <normalized project name>Abi with existing names. Here we need to decide on the approach. Is <normalized project name>Abi a reserved name? What if it exists in some of the dependencies in some module?

  • Support for multiple impl Contract { ... } blocks. Currently, we will get confusing compilation errors on name clashing since for each block we insert <normalized project name>Abi into the namespace. Solution for this and the previous point needs to be considered together.

  • Removing Abi suffix from the generated ABI name. Having Abi suffix is against Sway conventions for naming ABIs. Note that this change is a breaking change and should come with a forc migrate migration that changes all usages of <normalized project name>Abi with <normalized project name>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompilerGeneral compiler. Should eventually become more specific as the issue is triagedcompiler: frontendEverything to do with type checking, control flow analysis, and everything between parsing and IRgen

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions