Skip to content

Display errors generated when inlining fails implicit search #11101

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
bishabosha opened this issue Jan 13, 2021 · 1 comment · Fixed by #9984
Closed

Display errors generated when inlining fails implicit search #11101

bishabosha opened this issue Jan 13, 2021 · 1 comment · Fixed by #9984
Labels
area:inline area:reporting Error reporting including formatting, implicit suggestions, etc itype:enhancement
Milestone

Comments

@bishabosha
Copy link
Member

bishabosha commented Jan 13, 2021

When a given instance is generated by a macro and the macro fails, it would be useful to see which errors were generated in expansion, rather than only see the method that was attempted.

Minimized code

class FailHere

trait TC[T]
object TC {

  inline def mkDefaultTC[A]: TC[A] = inline compiletime.erasedValue[A] match {
    case _: FailHere => compiletime.error("blow up here")
    case _           => ???
  }

  inline given [T]: TC[T] = mkDefaultTC[T]
}

def test =
  summon[TC[Int]] // ok
  summon[TC[FailHere]] // error: no implicit argument of type TC[FailHere] was found
  TC.mkDefaultTC[FailHere] // error: blow up here

Output

-- Error: sandbox/mirror/example.scala:16:22 -----------------------------------
16 |  summon[TC[FailHere]] // error: no implicit argument of type TC[FailHere] was found
   |                      ^
   |no implicit argument of type TC[FailHere] was found for parameter x of method summon in object Predef.
   |I found:
   |
   |    TC.given_TC_T[FailHere]
   |
   |But method given_TC_T in object TC does not match type TC[FailHere].
-- Error: sandbox/mirror/example.scala:17:16 -----------------------------------
17 |  TC.mkDefaultTC[FailHere] // error: blow up here
   |  ^^^^^^^^^^^^^^^^^^^^^^^^
   |  blow up here
2 errors found

Expectation

I would also like to see the "blow up here" error for summon[TC[FailHere]], for example, we already see that given_TC_T was attempted so maybe the error can say that But method given_TC_T failed with errors: ...

@bishabosha bishabosha added itype:bug area:reporting Error reporting including formatting, implicit suggestions, etc itype:enhancement and removed area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug labels Jan 13, 2021
@nicolasstucki nicolasstucki linked a pull request Jan 13, 2021 that will close this issue
@nicolasstucki
Copy link
Contributor

This might be fixed by #9984. See https://github.com/lampepfl/dotty/pull/9984/files#diff-682cdfd833686fd57486c36d95f76e064006935841d14726a2c4e87f06589ac4R1-R4

@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:inline 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