- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.1k
 
Closed
Closed
Copy link
Labels
area:positionsarea:private optionsIssues tied to -Y private/internal compiler settings.Issues tied to -Y private/internal compiler settings.itype:bug
Description
Compiler version
3.7.4-RC3
Minimized code
lihaoyi scala3$ bin/scala -Ymagic-offset-header:MAGIC
scala> import scala.quoted.*
     | def lineImpl(using Quotes): Expr[Int] = {
     |   val sourceFile = quotes.reflect.Position.ofMacroExpansion.sourceFile
     |   val line = quotes.reflect.Position.ofMacroExpansion.startLine + 1
     |   Expr(line)
     | }
     | inline implicit def generate: Int = ${ lineImpl }
     | 
def lineImpl(using x$1: scala.quoted.Quotes): scala.quoted.Expr[Int]
def generate: Int
scala> {
     | 
     | 
     | ///MAGIC:build.sbt
     | def foo = generate
     | def bar = ???
     | println(foo)
     | bar
     | }
5
scala.NotImplementedError: an implementation is missing
  at scala.Predef$.$qmark$qmark$qmark(Predef.scala:344)
  at rs$line$12$.bar(rs$line$12:2)
  ... 30 elided
See how println(foo) prints out 5, because the line is not offset by ///MAGIC:build.sbt, even though bar causes a stack trace with line number :2 because it is properly offset
Expectation
I would expect quotes.reflect.Position.ofMacroExpansion to reflect the -Ymagic-offset-header, just like compile errors and runtime bytecode locations do
Metadata
Metadata
Assignees
Labels
area:positionsarea:private optionsIssues tied to -Y private/internal compiler settings.Issues tied to -Y private/internal compiler settings.itype:bug