Gleam: Error for multiple external functions with the same name

Created on 27 Nov 2019  Â·  9Comments  Â·  Source: gleam-lang/gleam

bug good first issue help wanted

All 9 comments

What is the issue exactly? I just cloned master @ 3f77601 and compiled successfully with only a warning.

It should not compile. Gleam does not allow multiple functions with the
same name but due to a mistake of my part an error is not emitted when
multiple external functions are created with the same name.

This goes for when the arity is different as well as when it is the same.
Unlike in Erlang two functions with the same name and different arity are
the same (invalid) function.

On Mon, 2 Dec 2019, 05:30 Logan Magee, notifications@github.com wrote:

What is the issue exactly? I just cloned master @ 3f77601
https://github.com/gleam-lang/gleam/commit/3f77601a9316929889aee43f0ee29df2f0288121
and compiled successfully with only a warning.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/gleam-lang/gleam/issues/328?email_source=notifications&email_token=ABOZVBW6H6MDA5DF3JL4EGDQWSMONA5CNFSM4JSLZL7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFSI3FQ#issuecomment-560237974,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABOZVBS2KXAILW5EKW44KWLQWSMONANCNFSM4JSLZL7A
.

So to clarify, the issue is not concerning duplicate function names in the compiler code; the problem is that the compiler can't catch that type of error when compiling gleam code. Is that correct?

If I do understand correctly now, does gleam support function overloading? I'm assuming not after searching the website (your comment seems to suggest this as well), but I want to be certain.

Yes I think you've got it right. The issue is that there is a bug in the compiler where it erroneously allows the programmer to define two external functions with the same name. This results incorrect Erlang code being generated as the compiler should not have accepted the module with 2 external functions of the same name as it does not conform to the Gleam specification.

It should be relatively straightforward to fix this by re-using the code for detecting this for regular functions. https://github.com/gleam-lang/gleam/blob/3f77601a9316929889aee43f0ee29df2f0288121/src/typ.rs#L1607-L1614

Gleam does not support function overloading at present but it may be something we wish to explore in future.

Okay, I understand. Thanks for the tip. I'll try to give this a shot over the next few days and let you know if it goes too far over my head.

Awesome! Thank you!

If you get stuck or have any questions please do open a draft PR and I'll offer any help I can. The code probably isn't the most clear to people unfamiliar with it.

Thank you! I needed something Rust to contribute to for practice.

I'll be sure to do that. Doing some code browsing won't hurt either.

Hi @lberrymage, I'm gearing up for a v0.5 release soon. Let me know if would like a second pair of eyes on this fix :)

Sorry, I've gotten really busy lately and haven't had ample time to work on this.

That would be fantastic. If you want to go ahead and fix it, I don't want to hold you back on your release by any means, but I can try to dedicate time to this shortly.

Was this page helpful?
0 / 5 - 0 ratings