Skip to content
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

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 opened this issue Sep 20, 2024 · 0 comments
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label

Comments

@neko-kai
Copy link
Contributor

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)

@neko-kai neko-kai added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

No branches or pull requests

1 participant