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

Possibly incorrect check for lower bounds #15678

Closed
WojciechMazur opened this issue Jul 14, 2022 · 3 comments
Closed

Possibly incorrect check for lower bounds #15678

WojciechMazur opened this issue Jul 14, 2022 · 3 comments

Comments

@WojciechMazur
Copy link
Contributor

WojciechMazur commented Jul 14, 2022

Community build regression for https://github.com/johnhungerford/generic-schema (maintainer @johnhungerford)
Based on Open Community Build #2564
Part of #15647 regressions tracker

Compiler version

Works in 3.1.2
Fails in 3.1.3
Fails in 3.2.1-RC1-bin-20220712-7e20b81-NIGHTLY

Probably further minimization might be helpfull

Minimized code

type TypeName = String & Singleton

trait Subtype[T]:
  type Name <: TypeName
object Subtype:
  type Aux[T, N <: TypeName] = Subtype[T] { type Name = N }

trait SubtypeReplacer[N <: TypeName, NewSubT, R <: Tuple]:
  type Out
  def replace(subtypes: R, withSubtype: NewSubT): Out

object SubtypeReplacer {
  given found[N <: TypeName, NewSubT, OldT, Tail <: Tuple]
      : SubtypeReplacer[N, NewSubT, Subtype.Aux[OldT, N] *: Tail] with {
    type Out = NewSubT *: Tail

    override def replace(
        subtypes: Subtype.Aux[OldT, N] *: Tail,
        withSubtype: NewSubT
    ): Out = withSubtype *: subtypes.tail
  }

  def replace[N <: TypeName, NewSubT, R <: Tuple](
      typeName: N,
      from: R,
      withSubtype: NewSubT
  )(using
      strp: SubtypeReplacer[N, NewSubT, R]
  ): strp.Out = strp.replace(from, withSubtype)
}

Output

[error] ./test.scala:20:26: Type argument Tail does not conform to lower bound Tuple.Tail[Subtype.Aux[OldT, N] *: Tail]
[error]     ): Out = withSubtype *: subtypes.tail
[error]    

Expectation

Should compile

@griggt
Copy link
Contributor

griggt commented Jul 14, 2022

First bad commit is d1957e5 from #13780

@griggt
Copy link
Contributor

griggt commented Jul 15, 2022

This simpler example exhibits the same symptoms:

def foo[S, T, Tail <: Tuple](s: S *: Tail, t: T): T *: Tail = t *: s.tail
-- [E057] Type Mismatch Error: test.scala:1:64 ---------------------------------
1 |def foo[S, T, Tail <: Tuple](s: S *: Tail, t: T): T *: Tail = t *: s.tail
  |                                                                ^
  |  Type argument Tail does not conform to lower bound Tuple.Tail[S *: Tail]
  |
  |  Note: a match type could not be fully reduced:
  |
  |    trying to reduce  Tuple.Tail[S *: Tail]
  |    failed since selector  S *: Tail
  |    does not uniquely determine parameters _, xs in
  |      case _ *: xs => xs
  |    The computed bounds for the parameters are:
  |      _ >: S
  |      xs >: Tail <: Tuple
  |
  | longer explanation available when compiling with `-explain`

@odersky
Copy link
Contributor

odersky commented Jul 15, 2022

Thanks for narrowing it down! I guess that's then as specified.

@mbovel mbovel added area:typer and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jul 15, 2022
@odersky odersky closed this as completed Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants