Skip to content

Spurious erased-given-is-used error #11896

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
japgolly opened this issue Mar 26, 2021 · 2 comments · Fixed by #11900
Closed

Spurious erased-given-is-used error #11896

japgolly opened this issue Mar 26, 2021 · 2 comments · Fixed by #11900

Comments

@japgolly
Copy link
Contributor

Compiler version

3.0.0-RC2-bin-20210325-eeb8340-NIGHTLY

Minimized code

sealed trait X[A]
object X {
  erased given unit: X[Unit] = compiletime.erasedValue
}

def x[A](f: List[A])(using erased X[A]): Int =
  123

def y(f: List[Unit]): Int =
  x(f)

Output

[error] 12 |  x(f)
[error]    |      ^
[error]    |      getter unit is declared as erased, but is in fact used

Expectation

It should compile.

@nicolasstucki
Copy link
Contributor

Minimized

import scala.language.experimental.erasedDefinitions

type X
erased def x: X = compiletime.erasedValue

def foo(using erased X): Unit = ()

def test: Unit = foo(using x)

This only affects erased given parameters with no names. The parameter is not marked as erased.

@nicolasstucki
Copy link
Contributor

Workaround: name the erased parameters

- def x[A](f: List[A])(using erased X[A]): Int =
+ def x[A](f: List[A])(using erased xa: X[A]): Int =

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.

3 participants