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

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

Open
Y-Nak opened this issue Nov 26, 2024 · 0 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed ir

Comments

@Y-Nak
Copy link
Collaborator

Y-Nak commented Nov 26, 2024

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.
@Y-Nak Y-Nak added help wanted Extra attention is needed good first issue Good for newcomers ir labels Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed ir
Projects
None yet
Development

No branches or pull requests

1 participant