Skip to content

Heisenbug corruption/loss of surrounding tree with -Yretain-trees when a transparent macro with an implicit parameter is executed in the same file #21622

Open
@neko-kai

Description

@neko-kai

Compiler version

Tested on 3.5.1, 3.3.4-RC1, 3.3.4-RC2, 3.3.4-RC4

Minimized code

Best reproduction is on izumi library branch, to reproduce execute:

git clone https://github.com/7mind/izumi.git
cd izumi
git checkout bug/heisenbug-reproducer
sbt distage-extension-configJVM/Test/compile

The failure is also reproducible in the following scastie: https://scastie.scala-lang.org/ABzjHtjsTkW1BQlngBqLsw , but the scastie lacks the context of the surrounding library

Output

[error] -- Error: /private/tmp/izumi/distage/distage-extension-config/.jvm/src/test/scala/com/github/pshirshov/configapp/abc.scala:21:8
[error] 21 |    make[TestService1[F]].from[TImpl[F]]
[error]    |    ^^^^^^^^^^^^^^^^^^^^^
[error]    |ClassConstructor failure: com.github.pshirshov.configapp.TestService1[F] is a Factory, use `makeFactory` or `make[X].fromFactory` to wire factories.

Expectation

The error is an internal library error that happens because the make macro call somehow receives a corrupt/empty surrounding tree that lacks the subsequent .from call that the make macro expects to find.

I call this a Heisenbug because it appears rarely and it will disappear if you make any minor modification to the affected file, such as add a newline or a comment [1].

The way this bug may be "fixed" is also extremely weird, replacing implicit m: Mirror.Of[A] with using m: Mirror.Of[A] in another (transparent) macro (makeConfig) that's executed in the same file "fixes" the issue 7mind/izumi@e7de8b1 (git checkout bug/heisenbug-reproducer-fixer in the above repo)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions