1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
discard """
output: '''
hi
hi
topLevel|topLevel|
topLevel2|topLevel2|
inProc|inProc|
inProc2|inProc2|
topLevel|9
topLevel2|10
inProc|7
inProc2|8
must have been the wind..
I'm there
must have been the wind..
I'm there
symbol'a'symbol'a'
symbol'b'symbol'b'
symbol'a'symbol'b'
symbol'a'9
symbol'b'9
symbol'a'0
'''
"""
import mdefaultprocparam
p()
proc testP =
p()
testP()
proc p2(s: string, count = s): string = s & count
proc testP2 =
echo p2 """inProc|"""
echo p2 """inProc2|"""
echo p2 """topLevel|"""
echo p2 """topLevel2|"""
testP2()
import macros
macro dTT(a: typed) = echo a.treeRepr
proc p3(s: string, count = len(s)): string = s & $count
proc testP3 =
echo p3 """inProc|"""
echo p3 """inProc2|"""
echo p3 """topLevel|"""
echo p3 """topLevel2|"""
testP3()
proc cut(s: string, c = len(s)): string =
s[0..<s.len-c]
echo "must have been the wind.." & cut "I'm gone"
echo cut("I'm gone", 4) & "there"
proc testCut =
echo "must have been the wind.." & cut "I'm gone"
echo cut("I'm gone", 4) & "there"
testCut()
var a = "symbol'a'"
var b = "symbol'b'"
block:
echo p2(a)
block:
echo p2(b)
block:
echo p2(a, b)
block:
echo p3(a)
echo p3(b)
echo p3(a, 0)
# bug #12252
proc foo(a = 0, b = a.high, c = high(typeof(a))) =
discard
foo()
|