Skip to content

-Wunused gives endless false positives on macros #16863

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
markehammons opened this issue Feb 9, 2023 · 1 comment · Fixed by #17061
Closed

-Wunused gives endless false positives on macros #16863

markehammons opened this issue Feb 9, 2023 · 1 comment · Fixed by #17061
Assignees
Labels
area:linting Linting warnings enabled with -W or -Xlint itype:bug
Milestone

Comments

@markehammons
Copy link

markehammons commented Feb 9, 2023

Compiler version

3.3.0-RC2

Minimized code

Unused implicit parameter

import scala.quoted.* 

def fn(using Quotes) = 
	val x = Expr(1)
	'{$x + 2}

https://scastie.scala-lang.org/mfwnZy5NSjW9nGh43ufJqQ

import scala.quoted.* 

def fn[A](using Quotes, Type[A]) = 
	val numeric = Expr.summon[Numeric[A]].getOrElse(???)
	'{$numeric.fromInt(3)}

https://scastie.scala-lang.org/6VG2SNfEQCCo7002RzYlfg

Unused local definition

import scala.quoted.* 

def fn[A](expr: Expr[Any])(using Quotes) = 
	val imp = expr match 
		case '{${_}: a} => Expr.summon[Numeric[a]]

	println(imp)

https://scastie.scala-lang.org/QCGlRnK7QrKX0eIIq7TjiQ

Unused import

import scala.quoted.* 
import scala.compiletime.asMatchable

def fn[A](using Quotes, Type[A]) = 
  import quotes.reflect.*
  val imp = TypeRepr.of[A].widen.asMatchable match 
    case Refinement(_,_,_) => ()
  println(imp)

https://scastie.scala-lang.org/X0hFgQK3Rz2K5jVXDyD2BA

Output

There are false positives on non-use of quotes and type in these examples.

Expectation

There shouldn't be false positives.

@markehammons markehammons added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 9, 2023
@jchyb jchyb added area:reporting Error reporting including formatting, implicit suggestions, etc area:linting Linting warnings enabled with -W or -Xlint and removed stat:needs triage Every issue needs to have an "area" and "itype" label area:reporting Error reporting including formatting, implicit suggestions, etc labels Feb 9, 2023
@Kordyjan Kordyjan added this to the 3.3.0 backports milestone Feb 20, 2023
@szymon-rd
Copy link
Contributor

szymon-rd commented Mar 6, 2023

The simplest solution for these errors would be to:

  • Filter out unused symbols with$ in their name.
  • Filter out unused imports from compiletime / event better - transparent inlines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:linting Linting warnings enabled with -W or -Xlint itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants