fe-lang / sonatina

Apache License 2.0
47 stars 6 forks source link

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

Open Y-Nak opened 6 days ago

Y-Nak commented 6 days ago

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: