Skip to content

Regression in implicit resoultion for arguments passed by name #18123

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 3, 2023 · 3 comments · Fixed by #18130
Closed

Regression in implicit resoultion for arguments passed by name #18123

WojciechMazur opened this issue Jul 3, 2023 · 3 comments · Fixed by #18130
Assignees
Labels
area:implicits related to implicits itype:bug regression This worked in a previous version but doesn't anymore
Milestone

Comments

@WojciechMazur
Copy link
Contributor

Regression found in Open Communtiy Build in 2 projects:

Compiler version

3.3.2-RC1-bin-20230622-9f15be2-NIGHTLY

Bisect points to eb38e1f

Minimized code

trait P[+T]

extension [T](inline parse0: P[T]) {
  inline def |[V >: T](inline other: P[V]): P[V] = ???
}

// Works if: 
// - parse0 is passed by value or
// - when rep has empty argument list, i.e:  def rep[V]()(using repeater: Implicits.Repeater[T, V]): P[V]
extension [T](inline parse0: => P[T]) {
  inline def rep[V](inline min: Int = 0)(using repeater: Implicits.Repeater[T, V]): P[V] = ???
}

object Implicits {
  trait Repeater[-T, R]
  object Repeater {
    implicit def GenericRepeaterImplicit[T]: Repeater[T, Seq[T]] = ???
  }
}

sealed trait RegexTree
abstract class Node extends RegexTree
class CharClassIntersection() extends Node

def classItem: P[RegexTree] = ???
def charClassIntersection: P[CharClassIntersection] = ???

def x = {
  (charClassIntersection.rep() | classItem.rep())
}

Output

-- [E172] Type Error: /Users/wmazur/projects/dotty/bisect/main.scala:31:33 -----
31 |  (charClassIntersection.rep() | classItem.rep())
   |                                 ^^^^^^^^^^^^^^^
   |No given instance of type Implicits.Repeater[RegexTree, V] was found.
   |I found:
   |
   |    Implicits.Repeater.GenericRepeaterImplicit[T]
   |
   |But method GenericRepeaterImplicit in object Repeater does not match type Implicits.Repeater[RegexTree, V]
   |
   |where:    V is a type variable with constraint <: Seq[CharClassIntersection]

Expectation

Should compile

@WojciechMazur WojciechMazur added itype:bug area:implicits related to implicits regression This worked in a previous version but doesn't anymore labels Jul 3, 2023
julienrf added a commit to scalacenter/dotty that referenced this issue Jul 4, 2023
@julienrf julienrf linked a pull request Jul 4, 2023 that will close this issue
@julienrf
Copy link
Contributor

julienrf commented Jul 4, 2023

@WojciechMazur I've submitted a possible fix in #18130. Is there an easy way to confirm that it fixes both projects weapon-regex and kittens?

@WojciechMazur
Copy link
Contributor Author

@julienrf I've started a runs for them in Open CB using your PR:

@julienrf
Copy link
Contributor

julienrf commented Jul 4, 2023

Thank you! They both passed the CI

@julienrf julienrf assigned odersky and unassigned julienrf Jul 4, 2023
julienrf added a commit to scalacenter/dotty that referenced this issue Jul 6, 2023
We apply the full fix under `-source future` only, and a partial fix otherwise.

This is a followup of scala#17924 that fixes the source incompatibilities reported in scala#18123.

We test that the behavior under `-source future` still fixes scala#9685, and that without `-source future` we fix both scala#9685 and scala#18123.
julienrf added a commit to scalacenter/dotty that referenced this issue Jul 6, 2023
We apply the full fix under `-source future` only, and a partial fix otherwise.

This is a followup of scala#17924 that fixes the source incompatibilities reported in scala#18123.

We test that the behavior under `-source future` still fixes scala#9685, and that without `-source future` we fix both scala#9685 and scala#18123.
julienrf added a commit to scalacenter/dotty that referenced this issue Jul 6, 2023
We apply the full fix under `-source future` only, and a partial fix otherwise.

This is a followup of scala#17924 that fixes the source incompatibilities reported in scala#18123.

We test that the behavior under `-source future` still fixes scala#9685, and that without `-source future` we fix both scala#9685 and scala#18123.
bishabosha pushed a commit that referenced this issue Jul 10, 2023
@Kordyjan Kordyjan added this to the 3.4.0 milestone Aug 1, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 11, 2024
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:implicits related to implicits 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.

4 participants