gleam icon indicating copy to clipboard operation
gleam copied to clipboard

Emit an error when external modules and Gleam modules would collide

Open PaperLightbulb opened this issue 1 year ago • 6 comments

To replicate:

  • create a gleam program

  • create a mjs file with the same name (excluding the .mjs/.gleam extension) as one of your gleam files OR

  • create an erlang file with the same name as one of your gleam files

  • attempt to import an external gleam function from one of the external files with the same name

Problem: Gleam will not recognize any exports from the .mjs or .erl and throw the following error: SyntaxError: The requested module '(mjs/erlang file path)' does not provide an export named '(imported external function name)' It would be much more clear if the error was specific to having a mjs or erlang file with the same name as a gleam file importing from it, instead of stating that the module does not have the specified export

PaperLightbulb avatar Mar 16 '24 19:03 PaperLightbulb

Thank you

lpil avatar Mar 17 '24 12:03 lpil

Hey @lpil do you mind if I pick up this issue?

louiidev avatar Mar 18 '24 00:03 louiidev

Go for it! Thank you

lpil avatar Mar 18 '24 00:03 lpil

I've just ran into this issue with using @external(erlang, "zlib", "open"), and naturally naming the file zlib.gleam. The error is even more unclear in this case, where it just says "function open/0 undefined". Definitely interested in seeing this resolved.

PastMoments avatar Apr 13 '24 23:04 PastMoments

@louiidev are you still planning to work on this? Otherwise I could try and pick it up

giacomocavalieri avatar Jun 21 '24 14:06 giacomocavalieri

@louiidev are you still planning to work on this? Otherwise I could try and pick it up

Go ahead

louiidev avatar Jun 21 '24 14:06 louiidev