Skip to content

Add note of separate compilation unit in macro's code example #4541

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

Merged
merged 1 commit into from
May 22, 2018

Conversation

mosyp
Copy link

@mosyp mosyp commented May 17, 2018

Old docs (https://docs.scala-lang.org/overviews/macros/overview.html#a-complete-example) has a paragraph which says:

An important aspect of macrology is separate compilation. To perform macro expansion, compiler needs a macro implementation in executable form. Thus macro implementations need to be compiled before the main compilation, otherwise you might see the following error:

However dotty throws unclear error so far so I opened and issue #4540 and submitted only simple note to code snippet as a remainder

Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Have an awesome day! ☀️

@@ -321,7 +321,8 @@ program that calls `assert`.
def assertImpl(expr: Expr[Boolean]) =
'{ if !(~expr) then throw new AssertionError(s"failed assertion: ${~expr}") }
}


// has to be in different compilation unit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can be even clearer.

}
object App {
   // has to be in a different compilation unit that depends on Macros

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense!

@nicolasstucki
Copy link
Contributor

@mentegy did you sigh the CLA?

@allanrenucci
Copy link
Contributor

CLA signed

@mosyp
Copy link
Author

mosyp commented May 22, 2018

@nicolasstucki done

@nicolasstucki
Copy link
Contributor

Thanks @mentegy

@nicolasstucki nicolasstucki merged commit 91de029 into scala:master May 22, 2018
@mosyp mosyp deleted the patch-1 branch May 22, 2018 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants