Skip to content
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

Better selection of name for ReassignmentToVal error message #22823

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jan-pieter
Copy link
Contributor

@jan-pieter jan-pieter commented Mar 17, 2025

(from today's Scala 3 compiler spree)

Use name from tree when it is a NameTree for the ReassignmentToVal error message

Fixes #22671

@SethTisue
Copy link
Member

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:

  1. is NameTree even the way to go here?
  2. can we assume that lhsCore is always a NameTree? does it make sense to keep the fallback case _ => lhsCore.symbol.name case?

@SethTisue
Copy link
Member

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...?

@som-snytt
Copy link
Contributor

som-snytt commented Mar 17, 2025

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.

@SethTisue
Copy link
Member

SethTisue commented Mar 17, 2025

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.

@SethTisue SethTisue assigned SethTisue and unassigned mbovel Mar 17, 2025
@SethTisue
Copy link
Member

SethTisue commented Mar 17, 2025

(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.)

@som-snytt
Copy link
Contributor

I submitted #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error says none for overloaded symbol
4 participants