Skip to content

Description of given instances in error messages is too low-level #11066

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

Closed
odersky opened this issue Jan 11, 2021 · 0 comments · Fixed by #11067
Closed

Description of given instances in error messages is too low-level #11066

odersky opened this issue Jan 11, 2021 · 0 comments · Fixed by #11067
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc itype:enhancement
Milestone

Comments

@odersky
Copy link
Contributor

odersky commented Jan 11, 2021

This code:

class PreferredPrompt(val preference: String)
object Greeter:
  def greet(name: String)(using prompt: PreferredPrompt) =
    println(s"Welcome, $name. The system is ready.")
    println(prompt.preference)
object JillsPrefs:
  given jillsPrompt: PreferredPrompt =
    PreferredPrompt("Your wish> ")
object JoesPrefs:
  given joesPrompt: PreferredPrompt =
    PreferredPrompt("relax> ")

import JillsPrefs.jillsPrompt
import JoesPrefs.joesPrompt
val x = Greeter.greet("Who's there?") // error

gives this error message:

-- Error: i11066.scala:15:37 ---------------------------------------------------
15 |val x = Greeter.greet("Who's there?")
   |                                     ^
   |ambiguous implicit arguments: both lazy value joesPrompt in object JoesPrefs and lazy value jillsPrompt in object JillsPrefs match type PreferredPrompt of parameter prompt of method greet in object Greeter

Expected

A description of JoesPrefs and JillsPrefs as given instances, not lazy vals. Lazy vals reveals underlying implementation details that should be omitted.

odersky added a commit to dotty-staging/dotty that referenced this issue Jan 11, 2021
odersky added a commit to dotty-staging/dotty that referenced this issue Jan 11, 2021
@nicolasstucki nicolasstucki added itype:enhancement area:reporting Error reporting including formatting, implicit suggestions, etc labels Jan 12, 2021
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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 itype:enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants