fixes #2220; #2219; breaks #2022; for #2022 callsite needs to be used

This commit is contained in:
Araq 2015-03-09 15:02:28 +01:00
commit 1efb5174f2
12 changed files with 290 additions and 171 deletions

View file

@ -1,5 +1,11 @@
# Bug #2022
discard """
output: '''@[97, 45]
@[true, false]
@[false, false]'''
"""
## The goal of this snippet is to provide and test a construct for general-
## purpose, random-access mapping. I use an AST-manipulation-based approach
## because it's more efficient than using procedure pointers and less
@ -31,6 +37,7 @@ type Mapped[Input; predicate: static[string]] = object
input: Input
macro map(input, predicate: expr): expr =
let predicate = callsite()[2]
newNimNode(nnkObjConstr).add(
newNimNode(nnkBracketExpr).add(
ident"Mapped",