summary refs log blame commit diff stats
path: root/tests/trmacros/tdisallowif.nim
blob: 36f60800e5da9c7a4c0e58cd249c99ef82e80dd6 (plain) (tree)
1
2
3
4
5
6
7
8
9
           
                                                           
          
                


                                        

                                                                            














                                                       
                


                      
         
discard """
  errormsg: "usage of 'disallowIf' is a user-defined error"
  line: 24
  disabled: true
"""

template optZero{x+x}(x: int): int = x*3
template andthen{`*`(x,3)}(x: int): int = x*4
template optSubstr1{x = substr(x, 0, b)}(x: string, 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 s[0] != "hi":
  echo "do it"
  echo "more branches"
else:
  discard