Skip to content

Invalid code passes scala.compiletime.testing.typeChecks with Generic Number Literals #11540

Closed
@benhutchison

Description

@benhutchison

In Scala 3-RC1, Im seeing some apparently flaky behavior from scala.compiletime.testing.typeChecks()

I have a test for compile-time checking of Generic Number Literals, almost exactly like Even in the dotty test codebase.
https://github.com/lampepfl/dotty/blob/ed5ecac22b2/tests/neg-macros/GenericNumLits/Test_2.scala#L5

The difference is Im using typeChecks in my unit test. Invalid number literals are reported as successfully type checking. If I take the exact same code outside of a typeCheck invocation, it fails to compile as expected.

Compiler version

3.0.0-RC1

Minimized code

Change line https://github.com/lampepfl/dotty/blob/ed5ecac22b2/tests/neg-macros/GenericNumLits/Test_2.scala#L5

println(scala.compiletime.testing.typeChecks("val e2: Even = 123"))

Output

true

Expectation

false

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions