Skip to content

Commit

Permalink
Added a test for invalid literal breaking the compiler
Browse files Browse the repository at this point in the history
Whenever a non-compilable expression is the first thing evaluated after the Scala Compiler is created, all further expressions fail with a
`scala.reflect.internal.FatalError: package scala does not have a member Nil`
  • Loading branch information
Konrad Najder committed Dec 29, 2023
1 parent 0543994 commit 95e270b
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.avsystem.scex.compiler

import com.avsystem.scex.compiler.ScexCompiler.CompilationFailedException
import com.avsystem.scex.japi.{DefaultJavaScexCompiler, JavaScexCompiler}
import org.scalatest.funsuite.AnyFunSuite

class InvalidLiteralTest extends AnyFunSuite with CompilationTest {
override protected def createCompiler: JavaScexCompiler = {
val settings = new ScexSettings
settings.classfileDirectory.value = "testClassfileCache"
//evaluating getter adapters fixes the problem (since the invalid expression isn't the first thing compiled)
settings.noGetterAdapters.value = true
new DefaultJavaScexCompiler(settings)
}

test("Invalid literal should not break the scex compiler") {
intercept[CompilationFailedException] {
evaluate[String]("11compilation_fail11")
}
assert("ok" == evaluate[String]("\"ok\""))
}
}

0 comments on commit 95e270b

Please sign in to comment.