feat: filenames in errors

This commit is contained in:
2025-03-13 14:57:35 +00:00
parent 67e85688b2
commit 00df2dc546
2 changed files with 19 additions and 8 deletions

View File

@@ -73,7 +73,7 @@ def frontend(
file: File
): Either[NonEmptyList[Error], microWacc.Program] =
parser.parse(contents) match {
case Failure(msg) => Left(NonEmptyList.one(Error.SyntaxError(msg)))
case Failure(msg) => Left(NonEmptyList.one(Error.SyntaxError(file, msg)))
case Success(fn) =>
val ast.PartialProgram(_, prog) = fn(file)
given errors: mutable.Builder[Error, List[Error]] = List.newBuilder
@@ -118,7 +118,7 @@ def compile(
_ <- logAction(s"Compilation failed for $filePath\nExit code: $code")
_ <- IO.blocking(
// Explicit println since we want this to always show without logger thread info e.t.c.
println(s"Compilation failed for ${filePath.toAbsolutePath}:\n$errorMsg")
println(s"Compilation failed for ${file.toPath.toRealPath()}:\n$errorMsg")
)
} yield code