-
Notifications
You must be signed in to change notification settings - Fork 28
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
Repeated shadow function definition across documents doesn't trigger error message #19
Comments
Hmmm I did not know about shadowing in Elm. I'm linting against this rule in JS/TS, but because the code in those languages is split into smaller modules, shadowing is easier to avoid. When you're saying that the error does not appear in branching narratives, do you mean the document that |
To clarify and test. We have two documents, ```elm {l}
myFunction : String
myFunction =
let
repeatedName =
"Hello"
in
repeatedName
``` and ---
follows: doc1
---
```elm {l}
repeatedName : String
repeatedName =
"world"
``` If you open both documents in Atom, viewing If the content of When code includes an attempt at shadowing, it is debatable as to whether conceptually the error is in (a) the first instance of the repeated name; (b) the second instance; (c) the local instance; (d) the global instance or (e) both instances. I think ideally we would report (e) indicating both instances of the repeated name (as Elm does normally). But for consistency, sticking to the principle that once an upstream document ( |
This appears to be an Atom-specific problem. If the two documents are opened in VSCode, error messages are indicated as expected, and clicking on the error takes you to the relevant document (either the first or second depending on which part of the message is selected). |
If you create a document containing the following two functions
the linter correctly reports the error
The name 'repeatedName' is first defined here: repeatedName = But then it is defined AGAIN over here: repeatedName =
, as Elm 0.19 does not allow shadowing of functions.However, if the code block defining
repeatedName
sits instead in a separate document thatfollows
the one that definesmyFunction
, the error persists (as we would expect), but no error message is reported (which is a litvis bug).This is likely to be problematic for beginners or anyone
following
a document they have not authored themselves, as it is quite a hard error to spot without a linter message.The problem is that a downstream modification can render an upstream local function in a separate document invalid. This can appear counterintuitive as local functions occupy a global namespace so making it doubly hard to spot without linter help.
The text was updated successfully, but these errors were encountered: