summary refs log tree commit diff stats
path: root/tests/template/mdotcall.nim
blob: 13dcbd82489efab7d0b53655311040cd7c31e528 (plain) (blame)
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
# issue #20073

type Foo = object
proc foo(f: Foo) = discard

template works*() =
  var f: Foo
  foo(f)

template boom*() =
  var f: Foo
  f.foo() # Error: attempting to call undeclared routine: 'foo'
  f.foo # Error: undeclared field: 'foo' for type a.Foo

# issue #7085

proc bar(a: string): string =
  return a & "bar"

template baz*(a: string): string =
  var b = a.bar()
  b

# issue #7223

import mdotcall2

type
  Bytes* = seq[byte]
  
  BytesRange* = object
    bytes*: Bytes
    ibegin*, iend*: int

proc privateProc(r: BytesRange): int = r.ibegin

template rangeBeginAddr*(r: BytesRange): pointer =
  r.bytes.baseAddr.shift(r.privateProc)

# issue #11733

type ObjA* = object

proc foo2(o: var ObjA) = discard
proc bar2(o: var ObjA, arg: Natural) = discard

template publicTemplateObjSyntax*(o: var ObjA, arg: Natural, doStuff: untyped) =
  o.foo2()
  doStuff
  o.bar2(arg)