Better selection of name for ReassignmentToVal error message
(from today's Scala 3 compiler spree)
Use name from tree when it is a NameTree for the ReassignmentToVal error message
Fixes #22671
assigning @mbovel as punishment for deserting us :-P
I put some commentary on the ticket about how we found our way to this approach
so then our questions for review are:
- is
NameTreeeven the way to go here? - can we assume that
lhsCoreis always aNameTree? does it make sense to keep the fallbackcase _ => lhsCore.symbol.namecase?
I'm also wondering why it wasn't done this way in the first place, tbh. like does using a symbol (instead of a plain name) in an error message sometimes improve message quality somehow...?
If I import a symbol, it might be renamed. Also, LHS of an assignment can be map(k) style.
Scala 2 expends some LOC on this error case. There is advice1 for does not convert to assignment and advice2 for receiver is not assignable.
I see. In that case, it sounds like it's worth doing some further exploring of whether we can get a hold of the right val with a little more work.
(I've assigned myself as a backstop, but @iusildra @jan-pieter @ajafri2001 if any of you wants to dig into this first, feel free, as I won't get to it right away.)
I submitted https://github.com/scala/scala3/pull/22869 where I'll add spree participants and deserters as co-conspirators. That just uses the other tree. But I'd also like to add the addendum when += fails to become update because of errors; that is fun syntax that is possibly underused.
Many months ago, I saved the format of the co-author tag so I wouldn't forget it, and what I saved was:
➜ ~ cat co-author
Co-authored-by: Jan-Pieter van den Heuvel
<[email protected]>
Superseded by https://github.com/scala/scala3/pull/22869