The error message you get when you shadow a def is very clear and helpful, but there are many instances where it is one of the first errors that gets reported, and is followed by several other confusing type errors caused by the shadowing. I always end up looking at the last error message first because it is the one visible right there in the terminal. Because of this, there have been many times where I've shadowed a def and then spent some time being confused by messy type errors because I don't see the shadowing error. It is frustrating to run into because the solution is always so simple.
If shadowing errors either caused type checking to fail immediately, or if they were reported last, this would no longer be an issue. Thoughts?
I saw a message from Ayaz agreeing about moving the shadowing error message to last but it seems to have disappeared. I created an issue about this here https://github.com/roc-lang/roc/issues/6335
I was actually going to make a post about this exact issue today because it was driving me up the wall :sweat_smile:
I have accidentally shadowed a variable name of an import deep inside another block of code. It took me an embarrassingly long amount of time to figure out what the hell was going on
But I hit this issue probably five times in 2 hours of coding
I think it's also made much worse inside an IDE because I can't actually see the shadow error if it's off the screen whereas if you run the compiler at least it shows up in the list
Yes it is definitely frustrating. I started looking at it tonight and will open a PR to change the ordering soon!
PR here
Unfortunately I don't think that will help the editor issue.
For that we really need some way to detect that a shadowing has occurred and show the error at the location a variable had been shadowed and then all references that would be shadowing if shadowing was possible.
Currently the error shows at the definition of the original variable which is basically useless
currently it looks like:
a="hi" #shadowing error
b=
a=10 #no error at all
c=a+1 #type error saying a is a string
Should look like :
a="hi" #no error
b=
a=10 #shadowing error
c=a+1 #error saying you shouldn't use a shadowed variable
I made a separate issue about language server display location because it's kind of a different domain https://github.com/roc-lang/roc/issues/6345
Great! For sure
Last updated: Jun 16 2026 at 16:19 UTC