summary refs log tree commit diff stats
path: root/compiler/parser.nim
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2012-04-14 13:26:47 +0300
committerZahary Karadjov <zahary@gmail.com>2012-04-14 13:32:51 +0300
commit42e0b082144a2c03ef18e0cabc372c90f1753148 (patch)
treef5812af6b9ab695a74633b3e20509ed4f2d92146 /compiler/parser.nim
parentf25c638dc4109445ce1476d6e6f18be034805a0a (diff)
downloadNim-42e0b082144a2c03ef18e0cabc372c90f1753148.tar.gz
fix the usage of definedInScope in pegs.=~
template `=~`*(s: string, pattern: TPeg): bool =
   when not definedInScope(matches):
      var matches: array[0..maxSubpatterns-1, string]

It seems that this never worked as intended.
I discovered it now, because when variables' names are preserved, multiple
variables named `matches` were created. The reason this happens is that
when the template is used as an if condition, the if scope is already entered,
but the variables end up in the outer scope.

This patch is consistent with how `expr` templates work, but makes the
definition of a variable injection template like := a bit harder, yet still possible.
(note that if foo := bar(): is still not creating properly scoped variable prior to the patch)
Diffstat (limited to 'compiler/parser.nim')
0 files changed, 0 insertions, 0 deletions