Skip to content

Regression in inference of implicit arguments #15664

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

Closed
WojciechMazur opened this issue Jul 13, 2022 · 3 comments · Fixed by #15679
Closed

Regression in inference of implicit arguments #15664

WojciechMazur opened this issue Jul 13, 2022 · 3 comments · Fixed by #15679

Comments

@WojciechMazur
Copy link
Contributor

WojciechMazur commented Jul 13, 2022

Community build regression for https://github.com/rssh/cps-async-connect (maintainer @rssh)
Based on Open Community Build #2434
Part of #15647 regressions tracker

This issue seems not to be related to avoidance changes introduced in 3.1.3 and reverts of that change as it compiles in both 3.1.1 and 3.1.3. It seems that the problem might be caused by the local Context type

Compiler version

Works with 3.1.1
Works with 3.1.3
Fails in 3.2.0-RC1
Fails in 3.2.1-RC1-bin-20220711-6efd92d-NIGHTLY

Minimized code

trait CpsMonad[F[_]]:
  type Context <: CpsMonadContext[F]
type Aux[F[_], C <: CpsMonadContext[F]] = CpsMonad[F] { type Context = C }
trait CpsMonadContext[F[_]]
trait CpsMonadInstanceContext[F[_]] extends CpsMonad[F]:
  type Context = CpsMonadInstanceContextBody[F]
class CpsMonadInstanceContextBody[F[_]](m: CpsMonadInstanceContext[F]) extends CpsMonadContext[F]
class InferAsyncArg[F[_], C <: CpsMonadContext[F]](using val am: Aux[F, C])

sealed abstract class ZManaged[-R, +E, +A]
type RManaged[-R, +A] = ZManaged[R, Throwable, A]

type ForZManaged[R, E] = [X] =>> ZManaged[R, E, X]
given zManagedCpsMonad[R, E]: CpsMonadInstanceContext[ForZManaged[R, E]] = ???

// Usage
def failing[R, E](using
    CpsMonad[ForZManaged[R, E]]
): InferAsyncArg[ForZManaged[R, E], CpsMonadInstanceContextBody[ForZManaged[R, E]]] =
  new InferAsyncArg

def compiling[R, E](using
    CpsMonad[ForZManaged[R, E]]
) =
  new InferAsyncArg[ForZManaged[R, E], CpsMonadInstanceContextBody[ForZManaged[R, E]]]

Output

[error] ./test.scala:23:3: Found:    InferAsyncArg[[X] =>> ZManaged[R, E, X], x$1.Context]
[error] Required: InferAsyncArg[ForZManaged[R, E], CpsMonadInstanceContextBody[ForZManaged[R, E]]]
[error]   new InferAsyncArg
[error]   ^^^^^^^^^^^^^^^^^

Expectation

It should compile

@odersky
Copy link
Contributor

odersky commented Jul 13, 2022

I think the failure to infer implicit issues need a bisect to pinpoint where they stopped working. Otherwise it's hopeless.

@griggt
Copy link
Contributor

griggt commented Jul 13, 2022

First bad commit is fe40c59 from #14840

@odersky
Copy link
Contributor

odersky commented Jul 13, 2022

I think what we observe here is the fuzz test boundary established by the huge number of projects we test. Many changes will trip something up, and often it is not immediately clear what it is. That's why we need minimizations and bisections. I am really thankful for everyone who makes this work.

@bishabosha bishabosha added area:community build and removed itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jul 14, 2022
@Kordyjan Kordyjan added this to the 3.2.1 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants