Skip to content

un-reduced summonFrom does not fallback to implicitNotFound #18681

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

Open
bishabosha opened this issue Oct 12, 2023 · 3 comments · May be fixed by #19490
Open

un-reduced summonFrom does not fallback to implicitNotFound #18681

bishabosha opened this issue Oct 12, 2023 · 3 comments · May be fixed by #19490
Assignees
Labels
area:inline area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug

Comments

@bishabosha
Copy link
Member

Compiler version

3.3.1

Minimized code

@annotation.implicitNotFound("there is no Missing!")
trait Missing

inline def summonMissing = compiletime.summonFrom {
  case m: Missing => m
}
inline def summonMissing2 = compiletime.summonInline[Missing]
val x = summonMissing
val y = summonMissing2

Output

-- Error: ----------------------------------------------------------------------
8 |val x = summonMissing
  |        ^^^^^^^^^^^^^
  |        cannot reduce summonFrom with
  |         patterns :  case given m @ _:Missing
  |-----------------------------------------------------------------------------
  |Inline stack trace
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  |This location contains code that was inlined from rs$line$1:4
4 |inline def summonMissing = compiletime.summonFrom {
  |                           ^
5 |  case m: Missing => m
6 |}
   -----------------------------------------------------------------------------
1 error found

Expectation

Like with summonInline we should show the custom error message:

-- [E172] Type Error: ----------------------------------------------------------
9 |val y = summonMissing2
  |        ^^^^^^^^^^^^^^
  |        there is no Missing!
  |-----------------------------------------------------------------------------
  |Inline stack trace
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  |This location contains code that was inlined from rs$line$1:7
7 |inline def summonMissing2 = compiletime.summonInline[Missing]
  |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   -----------------------------------------------------------------------------
2 errors found
@bishabosha bishabosha added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 12, 2023
@bishabosha bishabosha added area:reporting Error reporting including formatting, implicit suggestions, etc area:inline and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 12, 2023
@bishabosha
Copy link
Member Author

@soronpo I assigned you since you fixed the report for summonInline with #12428

@soronpo
Copy link
Contributor

soronpo commented Oct 13, 2023

I'll try to look at it. Things are kind of hectic here in Israel now, and I could use the distraction.

i10416 added a commit to i10416/dotty that referenced this issue Jan 19, 2024
This commit fixes the reporting issue where un-reduced summonFrom does not fallback to implicitNotFound.

Before this commit, `reduceInlineMatch` discarded the information from
implicit search in InlineReducer. This commit adds some changes so that
the error message from implicit search failure can propagate to
Inliner#typedMatchFinish to emit better error message.
@i10416 i10416 linked a pull request Jan 19, 2024 that will close this issue
@nicolasstucki
Copy link
Contributor

Alternative / workaround

inline def summonMissing = compiletime.summonFrom {
  case m: Missing => m
  case _ => compiletime.error("there is no Missing!")
}

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:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants