-
Notifications
You must be signed in to change notification settings - Fork 663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Elm allows invalid JavaScript identifier names; runtime failure #710
Comments
@evancz @achudnov should this be considered an upstream ( |
I don't know elm's code, so I can't say for sure. However, if you determine that the problem stems from language-ecmascript, please, submit an issue ticket there: https://github.com/jswebtools/language-ecmascript/issues/new Also, I've had a quick look at the module you linked, and I fail to see anything there that is not in the library already or that is generic enough to warrant inclusion. As for the issue itself, I have two questions:
|
The cabal file has the restriction |
@mgold, if elm compiles with language-ecmascript < 0.16, this means that it certainly doesn't use I would recommend using |
I'm fairly certain we do want to allow this so based on what you're saying, |
You mean fixing bad identifiers? I don't think there's a way one can do this in a semantics-preserving way apart from removing bad characters or substituting them for a know safe one, e.g. Anyway, my recommendation stands. Although I don't know your code base, so take that with a grain of salt. If you figure out something that makes the issue go away or, at least, less painful in a way that does not rely on elm-specific stuff, I'd be happy to review an issue or a pull request for it. |
Just confirmed issue as still existing in Elm 0.16.
Most other invalid identifiers I have tried cause a (slightly confusing) compile error instead:
|
Track in #1377 |
|
It's always possible to expand the set of allowed characters later. The more urgent concern is if we're allowing a character that we don't like, which was the case with |
Elm allows identifier names such as
x²
, and uses them verbatim as JS variable names. However, because JS doesn't allow this name, it fails at runtime:Uncaught SyntaxError: Unexpected token ILLEGAL
I would expect Elm to either enforce the same identifier restrictions, or transform them at compilation (as it does with JavaScript reserved words).
For reference: Post about legal characters in JS identifiers
The text was updated successfully, but these errors were encountered: