question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

3.2.0 regression around match types

See original GitHub issue

Compiler version

3.2-RC1, 3.2-RC2, 3.2-RC3, 3.2-RC4

Minimized code

@main def main(): Unit =
  println(summon[Sum[Minus[Succ[Zero]], Minus[Succ[Zero]]] =:= Minus[Succ[Succ[Zero]]]])

sealed trait IntT
sealed trait NatT extends IntT
final case class Zero() extends NatT
final case class Succ[+N <: NatT](n: N) extends NatT
final case class Minus[+N <: Succ[NatT]](n: N) extends IntT

type NatSum[X <: NatT, Y <: NatT] <: NatT = Y match
  case Zero => X
  case Succ[y] => NatSum[Succ[X], y]

type NatDif[X <: NatT, Y <: NatT] <: IntT = Y match
  case Zero => X
  case Succ[y] => X match
    case Zero => Minus[Y]
    case Succ[x] => NatDif[x, y]

type Sum[X <: IntT, Y <: IntT] <: IntT = Y match
  case Zero => X
  case Minus[y] => X match
    case Minus[x] => Minus[NatSum[x, y]]
    case _ => NatDif[X, y]
  case _ => X match
    case Minus[x] => NatDif[Y, x]
    case _ => NatSum[X, Y]

Output

Cannot prove that Minus[NatSum[Succ[Succ[Zero]], NatT]] =:= Minus[Succ[Succ[Zero]]].

Note: a match type could not be fully reduced:

  trying to reduce  NatSum[Succ[Succ[Zero]], NatT]
  failed since selector  NatT
  does not match  case Zero => Succ[Succ[Zero]]
  and cannot be shown to be disjoint from it either.
  Therefore, reduction cannot advance to the remaining case

    case Succ[y] => NatSum[Succ[Succ[Succ[Zero]]], y]

Expectation

Code should compile, as in Scala 3.1.3.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
dwijnandcommented, Oct 25, 2022

We purposely backed out an overly restricting change because of the code that failed to compile because of it. So there was one patch version where it compiled and then not. So not a “regression” as I see it.

1reaction
smartercommented, Oct 18, 2022

We ruled out type avoidance (turning it off completely doesn’t make a difference), the issue does go away if canWidenAbstract is set to false in https://github.com/lampepfl/dotty/blob/96d4ccdcfc3e0ff4d62e969374b92b6db590ccd3/compiler/src/dotty/tools/dotc/core/TypeComparer.scala#L3139

Read more comments on GitHub >

github_iconTop Results From Across the Web

Regression with Stata Chapter 3 - OARC Stats - UCLA
In general, this type of analysis allows you to test whether the strength of the relationship between two continuous variables varies based on...
Read more >
Classification and regression - Spark 3.3.1 Documentation
This page covers algorithms for Classification and Regression. It also includes sections discussing specific classes of algorithms, such as linear methods, ...
Read more >
11. Correlation and regression - The BMJ
Complete correlation between two variables is expressed by either + 1 or -1. When one variable increases as the other increases the correlation...
Read more >
performance regression from 3.2.0 to 4.0.1 · Issue #853 - GitHub
I tried this same schema + instance with the usual optimization of creating Validator instance only once (ie. do what `jsonschema.validate() ...
Read more >
Chapter 9 Feb 27–Mar 5: Matching to Reduce Model ...
Use matching techniques to prepare data for use in estimating associations between a continuous outcome and binary independent variable. Choose regression ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found