A motivating example for the new bindSym behavior.

The example is a proof-of-concept logging library, allowing you to define
lexically-scoped environments where certain logging attributes are applied
automatically to all logging statements.

fixes tmacro1 (use of `bindSym` inside static blocks)
This commit is contained in:
Zahary Karadjov 2018-04-19 19:16:05 +03:00 • committed by Andreas Rumpf
commit 2b8bf8fc4a
5 changed files with 160 additions and 1 deletions

View file

@ -199,7 +199,7 @@ proc semBindSym(c: PContext, n: PNode): PNode =
if s != nil:
# we need to mark all symbols:
var sc = symChoice(c, id, s, TSymChoiceRule(isMixin.intVal))
if not getCurrOwner(c).isCompileTimeProc:
if not (c.inStaticContext > 0 or getCurrOwner(c).isCompileTimeProc):
# inside regular code, bindSym resolves to the sym-choice
# nodes (see tinspectsymbol)
return sc