diff options
author | Araq <rumpf_a@web.de> | 2012-08-30 22:55:32 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-08-30 22:55:32 +0200 |
commit | 1d14cb1ad8d4d98ea19daa2d5ab6ded59d58553a (patch) | |
tree | c32929ff723358f440415d7610fd283f58f17a91 /tests/reject | |
parent | 1786e3099141f6548e9f6cd4f4998d32f602b71d (diff) | |
download | Nim-1d14cb1ad8d4d98ea19daa2d5ab6ded59d58553a.tar.gz |
next steps towards term rewriting macros; simple examples work
Diffstat (limited to 'tests/reject')
-rw-r--r-- | tests/reject/tdisallowif.nim | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/reject/tdisallowif.nim b/tests/reject/tdisallowif.nim new file mode 100644 index 000000000..002bc7491 --- /dev/null +++ b/tests/reject/tdisallowif.nim @@ -0,0 +1,28 @@ +discard """ + line: 24 + errormsg: "usage of 'disallowIf' is a user-defined error" +""" + +template optZero{x+x}(x: int): int = x*3 +template andthen{x*3}(x: int): int = x*4 +template optSubstr1{x = substr(x, a, b)}(x: string, a, b: int) = setlen(x, b+1) + +template disallowIf{ + if cond: action + else: action2 +}(cond: bool, action, action2: stmt) {.error.} = action + +var y = 12 +echo y+y + +var s: array[0..2, string] +s[0] = "hello" +s[0] = substr(s[0], 0, 2) + +echo s[0] + +if true: + echo "do it" + echo "more branches" +else: + nil |