Skip to content

Typer regression in purplekingdomgames/ultraviolet #23237

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

Open
WojciechMazur opened this issue May 22, 2025 · 2 comments
Open

Typer regression in purplekingdomgames/ultraviolet #23237

WojciechMazur opened this issue May 22, 2025 · 2 comments
Labels
area:typer itype:bug regression This worked in a previous version but doesn't anymore

Comments

@WojciechMazur
Copy link
Contributor

Based on OpenCB failure in purplekingdomgames/ultraviolet - build logs

Compiler version

3.7.1-RC1
Last good release: 3.7.0-RC1-bin-20250222-4dc4668-NIGHTLY
First bad release: 3.7.0-RC1-bin-20250225-a25fe5e-NIGHTLY
Bisect points to 32ac2e6

3.7.0 is not affected

Minimized code

object types{
  final case class vec2(x: Float, y: Float)
  final case class vec4(x: Float, y: Float, z: Float, w: Float)
  object vec4:
    def apply(xy: vec2, z: Float, w: Float): vec4 = vec4(xy.x, xy.y, z, w)

  opaque type Shader[In, Out] = In => Out
  object Shader:
    inline def apply[In, Out](f: In => Out): Shader[In, Out] = f
    inline def apply[In](f: In => Unit): Shader[In, Unit]    = f
    inline def apply(body: => Any): Shader[Unit, Unit] = (_: Unit) => body
}
import types.*

class GLSLEnvTests {
  case class FragEnv(UV: vec2)

  inline def fragment: Shader[FragEnv, vec4] =
    Shader { env =>
      val x = env.UV
      vec4(env.UV, 0.0f, 1.0f)
    }
}

Output

Compiling project (Scala 3.7.2-RC1-bin-20250520-baac46c-NIGHTLY, JVM (21))
[error] ./example.scala:49:15
[error] value UV is not a member of Any
[error]       val x = env.UV
[error]               ^^^^^^
[error] ./example.scala:50:12
[error] value UV is not a member of Any
[error]       vec4(env.UV, 0.0f, 1.0f)
[error]            ^^^^^^

Expectation

@WojciechMazur WojciechMazur added itype:bug area:typer regression This worked in a previous version but doesn't anymore labels May 22, 2025
@WojciechMazur
Copy link
Contributor Author

Another reproducer based on unibas-gravis/scalismo

sealed trait Dim
trait _2D extends Dim
trait _3D extends Dim

sealed abstract class IntVector[D]
object IntVector{
  def apply[D](d: Array[Int]): IntVector[D] = ???
  def apply(x: Int, y: Int): IntVector2D = IntVector2D(x, y)
  def apply(x: Int, y: Int, z: Int): IntVector3D = IntVector3D(x, y, z)
}
case class IntVector2D(i: Int, j: Int) extends IntVector[_2D]
case class IntVector3D(i: Int, j: Int, k: Int) extends IntVector[_3D]

type DiscreteImage[D, A] = DiscreteField[D, DiscreteImageDomain, A]
class DiscreteField[D, DDomain[D] <: DiscreteDomain[D], A](val domain: DDomain[D], val data: IndexedSeq[A])  extends PartialFunction[PointId, A] {
  override def apply(v1: PointId) = ???
  override def isDefinedAt(ptId: PointId) = ???
}
object DiscreteField{
    implicit class DiscreteImageOps[D, A](discreteField: DiscreteField[D, DiscreteImageDomain, A]) {
      def apply(idx: IntVector[D]): A = ???
      def isDefinedAt(idx: IntVector[D]): Boolean = ???
  }
}
trait DiscreteDomain[D] 
trait DiscreteImageDomain[D] extends DiscreteDomain[D] 
final case class PointId(id: Int) extends AnyVal

def test[S](img: DiscreteImage[_3D, S]) = img(IntVector(1, 2, 3))
-- [E007] Type Mismatch Error: /Users/wmazur/projects/scala/sandbox/example.scala:58:56 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
58 |def test[S](img: DiscreteImage[_3D, S]) = img(IntVector(1, 2, 3))
   |                                                        ^^^^^^^
   |                                                        Found:    (Int, Int, Int)
   |                                                        Required: Array[Int]
   |
   | longer explanation available when compiling with `-explain` 

@Gedochao
Copy link
Contributor

cc @smarter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:typer itype:bug regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

No branches or pull requests

2 participants