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

Regression in getkyo/kyo for typer #20297

Closed
WojciechMazur opened this issue Apr 30, 2024 · 3 comments · Fixed by #20371
Closed

Regression in getkyo/kyo for typer #20297

WojciechMazur opened this issue Apr 30, 2024 · 3 comments · Fixed by #20371
Assignees
Labels
area:typer itype:bug regression This worked in a previous version but doesn't anymore
Milestone

Comments

@WojciechMazur
Copy link
Contributor

Based on OpenCB failure in getkyo/kyo - build logs

Compiler version

Last good release: 3.4.2-RC1-bin-20240311-02c2a6e-NIGHTLY
First bad release: 3.4.2-RC1-bin-20240312-3694d95-NIGHTLY
Exact bisect has failed due to errors when building compiler, could be caused by any of:
b28d4c1
2421581

Minimized code

sealed abstract class Kyo[+T, -S]
opaque type <[+T, -S] >: T = T | Kyo[T, S]

extension [T, S](v: T < S)
  inline def map[U, S2](inline f: T => U < S2): U < (S & S2) = ???

class Streams[V]
object Streams:
  def emitValue[V](v: V): Unit < Streams[V] = ???

opaque type Stream[+T, V, -S] = T < (Streams[V] & S)
object Stream:
  extension [T, V, S](s: Stream[T, V, S])
    def reemit[S2, V2](f: V => Unit < (Streams[V2] & S2)): Stream[T, V2, S & S2] = ???
    def filter[S2](f: V => Boolean < S2): Stream[T, V, S & S2] = reemit { v =>
      f(v).map {
        case false => ()
        case true  => Streams.emitValue(v)
      }
    }

Output

-- [E007] Type Mismatch Error: /Users/wmazur/projects/dotty/bisect/test.scala:18:39 
18 |        case true  => Streams.emitValue(v)
   |                      ^^^^^^^^^^^^^^^^^^^^
   |                      Found:    Unit < Streams[V]
   |                      Required: Unit < (S & S2)
   |

Expectation

Should compile

@WojciechMazur WojciechMazur added itype:bug area:typer regression This worked in a previous version but doesn't anymore labels Apr 30, 2024
@bishabosha
Copy link
Member

this also doesn't compile in 3.3.0, but it seems Kyo only targets 3.4.0

@WojciechMazur
Copy link
Contributor Author

That's correct, they target 3.4 due to some of missing features. What's important is the fact that this project actual is stress test for the typer, especially in areas of intersection/union types, extensions, inlines etc. One other recent issue #20154, I'm also preparing the second issue found in the same repo (not yet sure it it's the same a current reproducer)

@WojciechMazur
Copy link
Contributor Author

The second reproducer for which bisect points to b28d4c1

private object internal:
  opaque type TakeN >: Int <: Int = Int
  sealed abstract class Kyo[+T, -S]
  abstract class Effect[+E]
import internal.*
opaque type <[+T, -S] >: T = T | internal.Kyo[T, S]

object Vars:
  def apply[V]: Vars[V] = ???
class Vars[V] extends Effect[Vars[V]]:
  def run[T, S2](state: V)(value: T < (Vars[V] & S2)): T < S2 = ???
  def use[T, S](f: V => T < S): T < (Vars[V] & S) = ???

class Streams[V] extends Effect[Streams[V]]
object Streams:
  def emitValue[V](v: V): Unit < Streams[V] = ???

opaque type Stream[+T, V, -S] = T < (Streams[V] & S)
object Stream:
  extension [T, V, S](s: Stream[T, V, S]) {
    // Fails only when method is inlined
    inline def reemit[S2, V2](
        f: V => Unit < (Streams[V2] & S2)
    ): Stream[T, V2, S & S2] = ???
    def take(n: Int): Stream[T, V, S] =
      Vars[TakeN].run(n) {
        reemit { v =>
          Vars[TakeN].use { case n => () }
        }
      }
  }

Output:

[error] ./bisect/test.scala:27:11
[error] Found:    Unit < Vars[internal.TakeN]
[error] Required: Unit < (Streams[V] & (Streams[V] & S))
[error]           Vars[TakeN].use { case n => () }

odersky added a commit to dotty-staging/dotty that referenced this issue May 9, 2024
Reverts parts of scala#19922.

Fixes scala#20342, scala#20297

The logic that we should ignore declared result types of inline methods really only applies
to transparent inlines.
noti0na1 pushed a commit to dotty-staging/dotty that referenced this issue May 14, 2024
Reverts parts of scala#19922.

Fixes scala#20342, scala#20297

The logic that we should ignore declared result types of inline methods really only applies
to transparent inlines.
odersky added a commit to dotty-staging/dotty that referenced this issue Jun 11, 2024
Reverts parts of scala#19922.

Fixes scala#20342, scala#20297

The logic that we should ignore declared result types of inline methods really only applies
to transparent inlines.
odersky added a commit to dotty-staging/dotty that referenced this issue Jun 11, 2024
Reverts parts of scala#19922.

Fixes scala#20342, scala#20297

The logic that we should ignore declared result types of inline methods really only applies
to transparent inlines.
odersky added a commit that referenced this issue Jun 12, 2024
Reverts parts of #19922.

Fixes #20342 
Fixes #20297

The logic that we should ignore declared result types of inline methods
really only applies to transparent inlines.
@Kordyjan Kordyjan added this to the 3.5.1 milestone Jul 3, 2024
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

Successfully merging a pull request may close this issue.

6 participants