Skip to content

Duplicate quote pattern variable when referred in bounds #18250

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
nicolasstucki opened this issue Jul 19, 2023 · 0 comments · Fixed by #18133
Closed

Duplicate quote pattern variable when referred in bounds #18250

nicolasstucki opened this issue Jul 19, 2023 · 0 comments · Fixed by #18133
Labels
area:metaprogramming:quotes Issues related to quotes and splices itype:bug
Milestone

Comments

@nicolasstucki
Copy link
Contributor

Compiler version

3.3.2-RC1

Minimized code

import scala.quoted.*

def test(x: Expr[Any])(using Quotes): Unit =
  x match
    case '{ type t; type u <: t; () } =>
    case '{ type t <: Comparable[t]; () } =>

Output

-- [E005] Naming Error: t/Test.scala:5:12 --------------------------------------
5 |    case '{ type t; type u <: t; () } =>
  |            ^^^^^^^^^^^^^^^^^^^^^^^
  |            duplicate pattern variable: t
  |
  | longer explanation available when compiling with `-explain`
-- [E005] Naming Error: t/Test.scala:6:12 --------------------------------------
6 |    case '{ type t <: Comparable[t]; () } =>
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |            duplicate pattern variable: t
  |
  | longer explanation available when compiling with `-explain`

Expectation

This is an issue in the implementation of SIP-53 - Support for multiple references to the same type in quoted type patterns.

It should be equivalent to

import scala.quoted.*

def test(x: Expr[Any])(using Quotes): Unit =
  x match
    case '{ type t; type u <: `t`; () } =>
    case '{ type t <: Comparable[`t`]; () } =>
@nicolasstucki nicolasstucki added itype:bug area:metaprogramming:quotes Issues related to quotes and splices labels Jul 19, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 19, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 19, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 19, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 19, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 20, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 20, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 20, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 20, 2023
@Kordyjan Kordyjan added this to the 3.4.0 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metaprogramming:quotes Issues related to quotes and splices itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants