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

Nowarn for first typecheck of macro invocation #8077

Open
scabug opened this issue Dec 12, 2013 · 7 comments
Open

Nowarn for first typecheck of macro invocation #8077

scabug opened this issue Dec 12, 2013 · 7 comments

Comments

@scabug
Copy link

scabug commented Dec 12, 2013

It would be useful if macro invocations could get a free pass on warnings before expansion.

That way, a build can run with warnings turned high and fatal, even if a macro does something like turn "a pure expression [that] does nothing in statement position" into a productive member of society, for example, by wrapping a boolean in an assert.

Perhaps enable it with -Ymacro-no-warn, and perhaps try to buffer the warnings and emit them if there are warnings after expansion. (The old warnings may or may not be meaningful for a given macro.)

@scabug
Copy link
Author

scabug commented Dec 12, 2013

Imported From: https://issues.scala-lang.org/browse/SI-8077?orig=1
Reporter: @som-snytt
Affected Versions: 2.11.0-M7

@scabug
Copy link
Author

scabug commented Dec 19, 2013

@xeno-by said:
Could you provide a use case?

@scabug
Copy link
Author

scabug commented Dec 19, 2013

@som-snytt said:
Sorry, I think my test was bad that day. In fact, I don't see the warnings.

@scabug
Copy link
Author

scabug commented Apr 5, 2014

Teo Klestrup Röijezon (teozkr) said:
Running into this in a project of mine. It runs a block of statements, and replaces it with the REPL output. Using this triggers warnings for pure statements (like literals) in positions other than the last statement.

Declaration
Usage

@scabug
Copy link
Author

scabug commented Apr 5, 2014

@xeno-by said:
Even something as simple as this triggers the decribed issue:

import scala.reflect.macros.whitebox._
import scala.language.experimental.macros

object Macros {
  def impl(c: Context)(x: c.Tree) = {
    import c.universe._
    q"()"
  }

  def foo(x: Any): Any = macro impl
}

object Test extends App {
  Macros.foo {
    1
    2
  }
}

@scabug
Copy link
Author

scabug commented Apr 6, 2014

@som-snytt said:
Thanks for reopening. I was faked out that day because the warning is emitted on { 2 == 1 } but not on

{ val x = 1 ; 2 == x }

@SethTisue
Copy link
Member

scala/scala#8995 improves the situation w/r/t to "a pure expression does nothing in statement position" warnings in particular

@SethTisue SethTisue added this to the Backlog milestone Feb 16, 2024
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

2 participants