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

Unactionable warning: "Given search preference for ... will change." #22153

Closed
eed3si9n opened this issue Dec 6, 2024 · 3 comments · Fixed by #22189
Closed

Unactionable warning: "Given search preference for ... will change." #22153

eed3si9n opened this issue Dec 6, 2024 · 3 comments · Fixed by #22189
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages itype:bug

Comments

@eed3si9n
Copy link
Member

eed3si9n commented Dec 6, 2024

Compiler version

3.6.4-RC1-bin-20241204-a67dbb0-NIGHTLY

Minimized code

You can grab sbt/sbt develop branch fdc03b782a40ce1f04bcefcd7eb3dc45fa7927d0.

I'm guessing that the minimized repro is basically https://github.com/scala/scala3/blob/c61897d7e78bfea283f5a2e37215c3b528e7684f/tests/warn/i21036a.scala

trait A
trait B extends A
given b: B = ???
given a: A = ???

val y = summon[A] // warn

Output

Currently the compile fails because I have -Xfatal-warnings and there's a warning about a given search:

[warn] -- Warning: /sbt/protocol/src/main/contraband-scala/sbt/protocol/codec/SettingQuerySuccessFormats.scala:14:91
[warn] 14 |      val value = unbuilder.readField[sjsonnew.shaded.scalajson.ast.unsafe.JValue]("value")
[warn]    |                                                                                           ^
[warn]    |Given search preference for sjsonnew.JsonReader[sjsonnew.shaded.scalajson.ast.unsafe.JValue] between alternatives
[warn]    |  (SettingQuerySuccessFormats.this.JValueFormat :
[warn]    |  sjsonnew.JsonFormat[sjsonnew.shaded.scalajson.ast.unsafe.JValue])
[warn]    |and
[warn]    |  (SettingQuerySuccessFormats.this.JValueJsonReader :
[warn]    |  sjsonnew.JsonReader[sjsonnew.shaded.scalajson.ast.unsafe.JValue])
[warn]    |will change.
[warn]    |Current choice           : the first alternative
[warn]    |New choice from Scala 3.7: the second alternative

Expectation

I expect all warnings to be actionable. This type of "FYI" message should go into the release note or -Xmigration 3.5.0.

@eed3si9n eed3si9n added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 6, 2024
@Gedochao Gedochao added area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 6, 2024
@som-snytt
Copy link
Contributor

I don't juggle implicits, but I appreciate the need to make warnings progressive and useful.

I think this warning has the force of deprecation.

In this case, trivially, it should summon[B] to maintain behavior. This is similar to the change in inference of overriding method types, where you add the explicit type to pick a behavior. It is inconvenient noise, but not inactionable.

"I spent hours getting my house of implicit cards just right and you broke it" is more annoying.

Lukas invented cat=scala3-migration to cope more conveniently with migration noise. I remember categories are not as leveraged in dotty.

m-w.com has synonyms for actionable: functional, applicative, pragmatic.
and antonyms: academic, useless, armchair.
I chose to say inactionable because inaction (intentional or not) is the result.

@eed3si9n
Copy link
Member Author

m-w.com has synonyms for actionable: functional, applicative, pragmatic

Yes, in functional programming it's entirely conceivable, even pragmatic to define a tower of typeclasses like functor, apply, applicable, and monad. The change to summon the closest type like Applicative[List] as opposed to Monad[List] sounds great to me.

In this case, trivially, it should summon[B] to maintain behavior.

At least in this context, of JsonReader vs JsonFormat I'm not too concerned which one gets picked, but what I do care about is summoning the right typeclass, in this case JsonReader.

I chose to say inactionable because inaction (intentional or not) is the result.

I'd love to not take action, but with -Xfatal-warning, I am forced to take some action, so it's not even inactionable.

I remember categories are not as leveraged in dotty.

I just discovered https://scala-lang.org/2024/08/19/given-priority-change-3.7.html from reading https://scala-lang.org/news/3.6.2, and it seems like I can take one of the tree actions:

  1. -source:3.5
  2. -source:3.7
  3. @nowarn("msg=Given search preference")

If we put in numbers to error messages, we could do @nowarn("id=E205"), which might be better than category.

@eed3si9n
Copy link
Member Author

Here's my PR for this - #22189

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants