Skip to content

Incorrect position of error reported from macro in inline methods chain #13991

@dos65

Description

@dos65

This issue is based on scalameta/metals#3214

The position of error that was produced in inline context is unwrapped to the outermost one.
In case if it's a chain of inline calls, it's unclear where the actual error happens.

Example:

// InlineMac.scala
object InlineMac:
  
  inline def sample(inline expr: String): Int =
    ${ sampleImpl('expr) }
  
  def sampleImpl(expr: Expr[String])(using Quotes): Expr[Int] =
      import quotes.reflect.*
      report.errorAndAbort("Error", expr)
      
// Main.scala
object Main:
  def main(args: Array: String): Unit =
     inline def v2 = InlineMac.sample("foo")  // <- the actual error position was here
     inline def v1 = v2
     
     v2  // [error] Error <- reported error position is here - wrong

There is a difference between in error message between direct compiler usage and using bsp-client.
The default compiler reportee additionally adds lines like: This location contains code that was inlined from Main.scala:27 but I don't think that it helps a lot in this case.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions