Skip to content

Modify ModuleBuilder::declare_function to Return Error on Conflicting Declarations #91

@Y-Nak

Description

@Y-Nak

Currently, the ModuleBuilder::declare_function method updates the existing function declaration when a function with the same name is declared again. This behavior can unintentionally overwrite previous declarations, potentially leading to inconsistencies or unexpected behaviors in the module.

We propose changing this behavior so that declare_function returns a Result. If a function with the same name is already registered and its signature differs from the new declaration, the method should return an error instead of updating the existing declaration.

Proposed Changes:

  • Add BuilderError type

  • Modify Return Type:

    • Change the return type of ModuleBuilder::declare_function to return a Result<Function, BuilderError>
  • Conflict Detection:

    • Implement a check to determine if a function with the same name already exists.
    • If it exists and the signature matches, return the existing function.
    • If it exists and the signature differs, return an error indicating a conflicting declaration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions