Skip to content

Commit 91de029

Browse files
Merge pull request #4541 from mentegy/patch-1
Add note of separate compilation unit in macro's code example
2 parents c627a99 + 39a3360 commit 91de029

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

docs/docs/reference/principled-meta-programming.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,12 @@ program that calls `assert`.
322322
'{ if !(~expr) then throw new AssertionError(s"failed assertion: ${~expr}") }
323323
}
324324

325-
val program = {
326-
val x = 1
327-
Macros.assert(x != 0)
325+
// has to be in a different compilation unit that depends on Macros
326+
object App {
327+
val program = {
328+
val x = 1
329+
Macros.assert(x != 0)
330+
}
328331
}
329332

330333
Inlining the `assert` function would give the following program:

0 commit comments

Comments
 (0)