Skip to content

"position not set" error when using scala.util.Not and inline #9972

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
IndiscriminateCoding opened this issue Oct 8, 2020 · 1 comment · Fixed by #9975
Closed

"position not set" error when using scala.util.Not and inline #9972

IndiscriminateCoding opened this issue Oct 8, 2020 · 1 comment · Fixed by #9975

Comments

@IndiscriminateCoding
Copy link

Minimized code

notmacro/Main.scala:

package notmacro

import scala.util.Not

object Main extends App {
  summon[Not[T[Int]]]
}

notmacro/T.scala:

package notmacro

import scala.quoted._

case class T[A <: AnyKind](s: String)

object T {
  implicit inline def derived[A <: AnyKind]: T[A] = ${ reprImpl[A] }

  def reprImpl[A <: AnyKind](using t: Type[A])(using ctx: QuoteContext): Expr[T[A]] =
    '{ T[A]("") }
}

Output

java.lang.AssertionError: assertion failed: position not set for Int # 4099305 of class dotty.tools.dotc.ast.Trees$TypeTree in /home/<redacted>/src/main/scala/notmacro/Main.scala

Expectation

I expect useful error about missing implicit instance

@nicolasstucki
Copy link
Contributor

Minimized to

def test: Unit =
  summon[scala.util.Not[T[Int]]]
class T[A]
object T:
  implicit inline def derived[A]: T[A] = new T[A]

argSpan has no position here https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/typer/Inliner.scala#L701, which causes the crash later.

@nicolasstucki nicolasstucki changed the title "position not set" error when using scala.util.Not and macro "position not set" error when using scala.util.Not and inline Oct 9, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Oct 9, 2020
These spans may be used by the an implicit search `scala.util.Not` and will propagate to other trees in the search.
@nicolasstucki nicolasstucki linked a pull request Oct 9, 2020 that will close this issue
@nicolasstucki nicolasstucki self-assigned this Oct 9, 2020
odersky added a commit that referenced this issue Oct 11, 2020
Fix #9972: Add missing span on implicit search failures
@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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants