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

sbt clean required for project to build properly #19309

Closed
Bersier opened this issue Dec 20, 2023 · 9 comments
Closed

sbt clean required for project to build properly #19309

Bersier opened this issue Dec 20, 2023 · 9 comments

Comments

@Bersier
Copy link
Contributor

Bersier commented Dec 20, 2023

Compiler version

Scala 3.3.1
sbt 1.9.8
JDK 21.0.1

Unminimized code

github.com/Bersier/physical

Issue

The project builds fine when sbt clean compile is used.
If sbt compile is used afterwards without changing the code, it also runs fine.
If sbt compile is used afterwards with even one comment changed, the project doesn't build anymore.

See related issue.

@Bersier Bersier added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 20, 2023
@nicolasstucki nicolasstucki added area:incremental-compilation area:sbt-bridge and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 20, 2023
@bishabosha
Copy link
Member

did you try building with a 3.4 nightly?

@Bersier
Copy link
Contributor Author

Bersier commented Dec 20, 2023

When I tried it earlier today, I could reproduce it systematically. Now I can't reproduce it anymore... I have no idea what changed.

On the other hand, even with sbt clean, the project does not compile anymore with Scala 3.4.0-RC1-bin-20231219-eae8831-NIGHTLY...

@nicolasstucki
Copy link
Contributor

nicolasstucki commented Dec 20, 2023

What is the failure on 3.4.0-RC1-bin-20231219-eae8831-NIGHTLY?

@Bersier
Copy link
Contributor Author

Bersier commented Dec 20, 2023

@nicolasstucki I checked the errors, and they all seem to be about a breaking change in Scala 3.4: "The match type contains an illegal case". I was able to get rid of them by using the "-source:3.3" flag, as suggested in the error message.

Unfortunately, there are 34 such instances in my project. Is there any documentation on that new restriction?

Anyways, it's not related to the bug reported here, which I unfortunately cannot reproduce anymore.

@bishabosha
Copy link
Member

bishabosha commented Dec 20, 2023

@sjrd may want to advise on your match types, otherwise you can check SIP 56

@sjrd
Copy link
Member

sjrd commented Dec 21, 2023

Ah ah, you managed to have more illegal match types in a single library than in the entire ecosystem of all published Scala 3 libraries combined.

But in fact all your 34 match types come from the same issue: you're matching on an opaque type alias within the scope that sees its alias. So when you do

  type DimMap[F[_ <: IntT] <: IntT, D] = D match
    case Dim[l, t, p, m, q, n, c, a, aQ, aP, o1, o2, o3, o4, s, b] => Dim[
      F[l], F[t], F[p], F[m], F[q], F[n], F[c], F[a], F[aQ], F[aP], F[o1], F[o2], F[o3], F[o4], F[s], F[b]
    ]

inside the scope that sees Dim, Dim[...] = Double. It is literally an alias. So that collapses to

  type DimMap[F[_ <: IntT] <: IntT, D] = D match
    case Double => Dim[
      F[l], F[t], F[p], F[m], F[q], F[n], F[c], F[a], F[aQ], F[aP], F[o1], F[o2], F[o3], F[o4], F[s], F[b]
    ]

which cannot find unique answers to what is l, t, ..., b. Hence, it's illegal.

You can escape that issue by putting those match types in a different scope that does not see the alias behind Dim.

@Bersier
Copy link
Contributor Author

Bersier commented Dec 21, 2023

@sjrd Thank you for your help! I successfully moved those definitions out of the scope in which the opaque type is defined, and pushed the commit to GitHub. The updated code elicits some odd behavior from the nightly compiler, however...

When running (> time sbt clean run) the project as is (so with Scala 3.3.1) works as expected (also works without clean; maybe this issue should be closed, or renamed):

[success] Total time: 11 s, completed Dec 21, 2023, 6:07:26 AM

real    0m15.480s
user    1m2.762s
sys     0m5.185s

When running the project with 3.4.0-RC1-bin-20231219-eae8831-NIGHTLY and -source:3.3, it still works, albeit much more slowly:

[success] Total time: 35 s, completed Dec 21, 2023, 6:08:42 AM

real    0m41.063s
user    1m9.828s
sys     0m7.903s

When running the project with 3.4.0-RC1-bin-20231219-eae8831-NIGHTLY, but without -source:3.3, it fails dramatically. It first spits out many errors, the first one being:

[error] 15 |val electronVolt: Energy = 1.602176634e-19 * joule
[error]    |                                             ^^^^^
[error]    |Found:    (dimensional.dimension.Dimensions.joule :
[error]    |  dimensional.dimension.Dimensions.Energy)
[error]    |Required: dimensional.dimension.Dimensions.Dim[Ly, Ty, Py, My, Qy, Ny, Cy, Ay, AQy, APy,
[error]    |  O1y, O2y, O3y, O4y, Sy, By]

After that, it seems to hang indefinitely (at least 5 minutes).

@sjrd
Copy link
Member

sjrd commented Dec 21, 2023

That does seem like an entirely different issue, at this point, indeed. I suggest you close this one and open another one focused on what you are experiencing now.

@Bersier
Copy link
Contributor Author

Bersier commented Dec 22, 2023

I opened a new issue (during minimization, the hanging disappeared).

@Bersier Bersier closed this as completed Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants