Skip to content

Add missing position when expanding error #13872

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

Merged
merged 1 commit into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/typer/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ object Inliner {
lit(error.pos.column),
if kind == ErrorKind.Parser then parserErrorKind else typerErrorKind)

private def packErrors(errors: List[(ErrorKind, Error)])(using Context): Tree =
private def packErrors(errors: List[(ErrorKind, Error)], pos: SrcPos)(using Context): Tree =
val individualErrors: List[Tree] = errors.map(packError)
val errorTpt = ref(defn.CompiletimeTesting_ErrorClass)
val errorTpt = ref(defn.CompiletimeTesting_ErrorClass).withSpan(pos.span)
mkList(individualErrors, errorTpt)

/** Expand call to scala.compiletime.testing.typeChecks */
Expand All @@ -380,7 +380,7 @@ object Inliner {
/** Expand call to scala.compiletime.testing.typeCheckErrors */
def typeCheckErrors(tree: Tree)(using Context): Tree =
val errors = compileForErrors(tree)
packErrors(errors)
packErrors(errors, tree)

/** Expand call to scala.compiletime.codeOf */
def codeOf(arg: Tree, pos: SrcPos)(using Context): Tree =
Expand Down
1 change: 1 addition & 0 deletions compiler/test/dotc/pos-test-pickling.blacklist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ i7740a.scala
i7740b.scala
i6507b.scala
i12299a.scala
i13871.scala

# Tree is huge and blows stack for printing Text
i7034.scala
Expand Down
10 changes: 10 additions & 0 deletions tests/pos/i13871.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import scala.compiletime.{error, codeOf}
import scala.compiletime.testing.*

inline def testError(inline typeName: Any): String = error("Got error " + codeOf(typeName))

transparent inline def compileErrors(inline code: String): List[Error] = typeCheckErrors(code)

def test =
typeCheckErrors("""testError("string")""")
compileErrors("""testError("string")""")