Skip to content

Anonymous given name clash for tuples #6938

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
milessabin opened this issue Jul 26, 2019 · 5 comments
Closed

Anonymous given name clash for tuples #6938

milessabin opened this issue Jul 26, 2019 · 5 comments
Labels
area:implicits related to implicits itype:bug

Comments

@milessabin
Copy link
Contributor

I think this is only an issue for tuple types with arity > 1 ...

Given,

trait Foo[T]
object Foo {
  given [T] as Foo[Tuple1[T]] {}
  given [T, U] as Foo[(T, U)] {}
  given [T, U, V] as Foo[(T, U, V)] {}
}

The compiler will name the Tuple1 instance as Foo_Tuple1_given, but both the Tuple2 and Tuple3 instances are named Foo_Tuple_given which results in the above failing with,

-- Error: local/given-tuples.scala:6:8 -----------------------------------------
6 |  given [T, U, V] as Foo[(T, U, V)] {}
  |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |  Foo_Tuple_given is already defined as class Foo_Tuple_given
one error found
@travisbrown
Copy link
Contributor

FWIW I have a feature request for this here: lampepfl/dotty-feature-requests#59

(Int, Int) and (Int, String) will also collide, as will List[Int] and List[String], etc.

@milessabin
Copy link
Contributor Author

Oh, right. I'd say that was a bug rather than a feature request. Synthetic names should never clash.

@aappddeevv
Copy link

I just hit this and its a real error. All the tuples get crunched down to the same name (in the same package).

The work around is to wrap it or put it in another package, etc.

@smarter
Copy link
Member

smarter commented Sep 11, 2019

The work around is to wrap it or put it in another package, etc.

The simpler workaround is to give an explicit name to your givens.

@aappddeevv
Copy link

Oh, that's much simpler. Did not think of that.

milessabin added a commit that referenced this issue Oct 28, 2019
Fix #6938: Expand tuples when synthesizing given names
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
Projects
None yet
Development

No branches or pull requests

4 participants