elm / compiler

Compiler for Elm, a functional language for reliable webapps.
https://elm-lang.org/
BSD 3-Clause "New" or "Revised" License
7.48k stars 659 forks source link

Code generation creates identifiers starting with invalid characters #1763

Open MightyAlex200 opened 5 years ago

MightyAlex200 commented 5 years ago

Certain generated variable names start with the username of the account that published the package they're in. If that username begins with an invalid character (i.e. a number), the code generates errors and does not run. I discovered this while trying to use https://package.elm-lang.org/packages/1602/elm-feather/latest/

From what I can tell this is a problem introduced with the changes in 0.19, because I was using this same package in 0.18 without problems.

This error can be reproduced simply by compiling an Elm program using 1602/elm-feather, but I have a compilable example you can see here: https://github.com/MightyAlex200/Comet/tree/ui-elm-19 Just run make in ui/, then open index.html

Related to #1377 and #710

1602 commented 5 years ago

Example of generated code:

var 1602$json_schema$Json$Schema$Builder$SchemaBuilder = function (a) {
    return {$: 'SchemaBuilder', a: a};
};

(when using 1602/json-schema package)

1602 commented 5 years ago

Is there a plan to patch this bug within 0.19.x?

People keep asking me what to do if they want to use some of my elm libraries, I'd appreciate some insight here.

harrysarson commented 5 years ago

As a workaround you could run a find and replace on the generated Javascript.

evancz commented 5 years ago

Doing a new release of binaries is quite expensive. It takes maybe a three days to get everything set up, and then I need to have a testing phase for the community to see if it works on a bunch of different platforms. Then the folks who manage other install paths like npm, homebrew, and aur need to get things working.

All together, this is a pretty big cost across quite a lot of people, so I would like to get a decent number of fixes together before putting something out.

I don't know what the best path is in your scenario.

1602 commented 5 years ago

Yup, it makes sense to batch bug-fixes and release them all at once, given costs associated with the compiler release.

Speaking of my projects, I think it would be okay to rename.