Morpho-lang / morpho

The Morpho language 🦋. Morpho is a small embeddable language for scientific computing applications.
MIT License
33 stars 11 forks source link

More tests for multiple dispatch #266

Closed joshichaitanya3 closed 5 months ago

joshichaitanya3 commented 5 months ago

A few more tests for multiple dispatch. The namespace_for_new test implements a new signature for a function in the namespace, and Morpho does run that implementation. Not sure what the intended behavior is here. I feel like this should be allowed as it will allow users to re-use code nicely.

Not sure about the namespace_for_overwrite, which tries to redefine an already existing implementation from the namespace. I think this should just result in a standard multiple dispatch error of matching signatures.

duplicate_no_types_two_arguments is same as the duplicate test, but the signature doesn’t contain types. This works correctly. The duplicate_no_types however has duplicate functions with a single untyped argument, and this fails due to a segfault. So does the namespace_for_overwrite test.

The segfault is due to a compiler infinite loop (see block comments in the files for a backtrace).

Edit: Upon adding another duplicate test with a single typed argument that also fails, the problem seems to be for functions with one argument, and less to do with Type annotations.

softmattertheory commented 5 months ago

Great news, these were all from the same issue—mfcompile_set was failing to check whether the parameter had already been checked for single parameter functions. The same fix seems to repair all these failing examples. Thanks for these @joshichaitanya3!