Skip to content

Fix: Prevent GADT reasoning in pattern alternatives #22853

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

Merged
merged 1 commit into from
Mar 25, 2025

Conversation

Linyxus
Copy link
Contributor

@Linyxus Linyxus commented Mar 21, 2025

fixes #22805.

Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is the minimal sound but not complete fix, which is the right initial choice, so LGTM to merge.

@dwijnand dwijnand merged commit 701fa8a into scala:main Mar 25, 2025
29 checks passed
@dwijnand dwijnand deleted the gadt-pattern-alts branch March 25, 2025 09:05
@dwijnand
Copy link
Member

The alternative would be to leverage InPatternAlternative in the various parts where GADT reasoning is employed.

@Linyxus
Copy link
Contributor Author

Linyxus commented Mar 25, 2025

Seems that the community build fails on the merging commit; I checked the trace but it seems quite irrelevant. Looks like a random failure?

@dwijnand
Copy link
Member

Yes:

Error: All tests passed after retry, indicating that some tests are flaky.
Error: This build is configured to reject flaky tests.

@dwijnand
Copy link
Member

failing seed for hash.same as scala hashing is 02q7JmTZisk304fqzp3dLoasNHF2CNaWFypvZ7ENAhE=
failing seed for hash.same as scala hashing is Csk-rxF6Fu7wpOPKgrGSPkxdWfc2x5NtYbLDdFncwAD=
[error] ==> X cats.tests.ArraySeqSuite.ArraySeq[Int]: hash.same as scala hashing  0.049s munit.FailException: /__w/scala3/scala3/community-build/community-projects/cats/tests/shared/src/test/scala-2.13+/cats/tests/ArraySeqSuite.scala:81
[error] 80:    implicit val hash: Hash[ListWrapper[Int]] = ListWrapper.hash[Int]
[error] 81:    checkAll("ArraySeq[Int]", HashTests[ArraySeq[ListWrapper[Int]]].hash)
[error] 82:    checkAll("Hash[ArraySeq]", SerializableTests.serializable(Hash[ArraySeq[ListWrapper[Int]]]))
[error] 
[error] Failing seed: _7kS1maL5k9NcZRO4TRUfIVMHJormxFh7Pv-waVX43K=
[error] You can reproduce this failure by adding the following override to your suite:
[error] 
[error]   override val scalaCheckInitialSeed = "_7kS1maL5k9NcZRO4TRUfIVMHJormxFh7Pv-waVX43K="
[error] 
[error] Falsified after 44 passed tests.
[error] > Labels of failing property: 
[error] Expected: true
[error] Received: false
[error] > ARG_0: ArraySeq(ListWrapper(List(348318819)), ListWrapper(List()), ListWrapper(List(-1210464944, -2147483648, 2147483647, -1, 963531488, 1979816629)), ListWrapper(List(1082445307, -1008730567, -311475957, -264455900, 0, -1806307621, -415030663, 1412610993, -2147483648)), ListWrapper(List(-1, -1, -109795631, 697642861)), ListWrapper(List(1, 1, 1)))
[error] > ARG_1: ArraySeq(ListWrapper(List(1585039739)))
[error]     at munit.Assertions.fail(Assertions.scala:283)
[error]     at munit.Assertions.fail$(Assertions.scala:15)
[error]     at munit.FunSuite.fail(FunSuite.scala:11)
[error]     at munit.ScalaCheckSuite.propToTry$$anonfun$1(ScalaCheckSuite.scala:104)
[error]     at scala.util.Try$.apply(Try.scala:217)
[error]     at munit.ScalaCheckSuite.propToTry(ScalaCheckSuite.scala:104)
[error]     at munit.ScalaCheckSuite.$init$$$anonfun$1$$anonfun$1$$anonfun$1(ScalaCheckSuite.scala:46)
[error]     at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:475)
[error]     at munit.Suite$$anon$1.execute(Suite.scala:26)
[error]     at scala.concurrent.impl.Promise$Transformation.submitWithValue(Promise.scala:429)
[error]     at scala.concurrent.impl.Promise$DefaultPromise.submitWithValue(Promise.scala:338)
[error]     at scala.concurrent.impl.Promise$DefaultPromise.dispatchOrAddCallbacks(Promise.scala:312)
[error]     at scala.concurrent.impl.Promise$DefaultPromise.transform(Promise.scala:128)
[error]     at munit.internal.FutureCompat$ExtensionFuture.transformCompat(FutureCompat.scala:16)
[error]     at munit.ScalaCheckSuite.$init$$$anonfun$1$$anonfun$1(ScalaCheckSuite.scala:48)
[error]     at munit.GenericTest.withBodyMap$$anonfun$1(GenericTest.scala:33)
[error]     at munit.MUnitRunner.$anonfun$10(MUnitRunner.scala:296)
[error] Failed: Total 12846, Failed 1, Errors 0, Passed 12845
[error] Failed tests:
[error] 	cats.tests.ArraySeqSuite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unsound GADT constraints with pattern alternatives
3 participants