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

missleading error message (cyclic reference) with Macro-Annotations when typecheck doesn't work in the given context #57

Closed
FlorianKirmaier opened this issue Oct 21, 2014 · 3 comments

Comments

@FlorianKirmaier
Copy link

class TestTypecheck() extends StaticAnnotation {
    def macroTransform(annottees: Any*): Any = macro Predef.TestTypecheckImpl
  }
  def TestTypecheckImpl(c: whitebox.Context)(annottees: c.Tree*): c.Tree = {
    import c._
    import universe._

    //try {
    c.typecheck(q"val a: Int")
    //} catch {
    //  case e => e.printStackTrace
    //}
    annottees(0)
  }

object A2 { @TestTypecheck class B }

This doesn't compile, because we can't have undeclareds member inside of an object.

When we don't catch the Exception, we get an cyclic reference error and a StackTrace which doesn't lead to the cause. This is really ugly to debug.
When we print the exception of typecheck, we can at least find our code in the Stacktrace.

An error message like the following would be great:
scala.reflect.macros.TypecheckException: only classes can have declared but undefined members

A variation of this is probably the cause of the error message in #49.
#49

@xeno-by
Copy link
Member

xeno-by commented Oct 21, 2014

Thanks for reporting! I'll see what I can do. In the meanwhile, is this a blocker for you?

@FlorianKirmaier
Copy link
Author

This is not a blocker for me. It was only annoying to debug.
A simple way to improve the the userexperience could be, to log all exception, which are thrown inside of macros.

@xeno-by
Copy link
Member

xeno-by commented Nov 19, 2015

I've merged this issue into #75 and will close this issue now. If this is a blocker for you, please let me know, and we'll think of something.

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