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

Assertion fail in dotty.tools.dotc.core.TypeOps$.dominators$1(TypeOps.scala:248) using Coulomb+Sourcecode libs #17116

Open
benhutchison opened this issue Mar 15, 2023 · 1 comment
Labels
itype:bug itype:crash stat:needs minimization Needs a self contained minimization

Comments

@benhutchison
Copy link
Contributor

benhutchison commented Mar 15, 2023

Compiler version

3.3.0-RC3

Minimized code

I minimized what I'm seeing locally in a project down to this Scastie:
https://scastie.scala-lang.org/7QFQRDLcQBua2DedfMeUzQ

The code requires Coulomb and Sourcecode libraries to exhibit the error. Coulomb's opaque type Quantity[V, U] needs to be used, and the library needs to be exposed via export for the error to happen.

import cats.*
import cats.data.*
import cats.syntax.all.*

import sourcecode.{*, given}

object Exports:
  export coulomb.{Quantity, DeltaQuantity, /, `*`, ^}
  export coulomb.syntax.{withUnit, withDeltaUnit}
  object allalgebra extends algebra.instances.AllInstances
  export allalgebra.{*, given}
  export coulomb.ops.algebra.spire.all.{*, given}
  export coulomb.policy.spire.standard.given
  export coulomb.conversion.{UnitConversion, TruncatingUnitConversion}

import Exports.{given, *}

type EitherNecs[T] = EitherNec[String, T]

object Valid:
  def validateQtyGTE[T, V: Order, U](n: Text[Quantity[V, U]], threshold: Text[Quantity[V, U]], context: =>String = "", target: T = ()): EitherNecs[T] =
    if (n.value < threshold.value) then s"Invalid:$context ${n.source}=${n.value} <= ${threshold.source}=${threshold.value}".leftNec
    else target.rightNec

Valid.validateQtyGTE(1.withUnit[Unit], 0.withUnit[Unit])

println("done")

Locally I see an assertion fail at:

[error] java.lang.AssertionError: assertion failed
[error] scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
[error] dotty.tools.dotc.core.TypeOps$.dominators$1(TypeOps.scala:248)
[error] dotty.tools.dotc.core.TypeOps$.approximateOr$1(TypeOps.scala:382)
[error] dotty.tools.dotc.core.TypeOps$.orDominator(TypeOps.scala:395)
[error] dotty.tools.dotc.core.TypeOps$.approximateOr$1(TypeOps.scala:363)
[error] dotty.tools.dotc.core.TypeOps$.orDominator(TypeOps.scala:395)
[error] dotty.tools.dotc.core.TypeOps$.approximateOr$1(TypeOps.scala:370)
[error] dotty.tools.dotc.core.TypeOps$.orDominator(TypeOps.scala:395)
[error] dotty.tools.dotc.core.Types$OrType.join(Types.scala:3407)
[error] dotty.tools.dotc.core.Types$Type.goOr$1(Types.scala:857)
[error] dotty.tools.dotc.core.Types$Type.go$1(Types.scala:726)
[error] dotty.tools.dotc.core.Types$Type.findMember(Types.scala:873)
..snip..
@benhutchison benhutchison added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 15, 2023
@nicolasstucki
Copy link
Contributor

We need a self-contained version to reproduce it in the compiler tests.

@nicolasstucki nicolasstucki added stat:needs minimization Needs a self contained minimization and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:bug itype:crash stat:needs minimization Needs a self contained minimization
Projects
None yet
Development

No branches or pull requests

2 participants