summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/ccgexprs.nim2
-rw-r--r--tests/method/temptybody.nim11
2 files changed, 12 insertions, 1 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index 1ebf85771..e19341db5 100644
--- a/compiler/ccgexprs.nim
+++ b/compiler/ccgexprs.nim
@@ -1962,7 +1962,7 @@ proc expr(p: BProc, n: PNode, d: var TLoc) =
     var sym = n.sym
     case sym.kind
     of skMethod:
-      if sym.getBody.kind == nkEmpty or sfDispatcher in sym.flags:
+      if {sfDispatcher, sfForward} * sym.flags != {}:
         # we cannot produce code for the dispatcher yet:
         fillProcLoc(sym)
         genProcPrototype(p.module, sym)
diff --git a/tests/method/temptybody.nim b/tests/method/temptybody.nim
new file mode 100644
index 000000000..26285d05b
--- /dev/null
+++ b/tests/method/temptybody.nim
@@ -0,0 +1,11 @@
+# bug #2401
+
+type MyClass = ref object of RootObj
+
+method HelloWorld*(obj: MyClass) =
+  when defined(myPragma):
+    echo("Hello World")
+  # discard # with this line enabled it works
+
+var obj = MyClass()
+obj.HelloWorld()
<ono@java.pl> 2015-09-04 23:03:22 +0200 compiler: Trim .nim files trailing whitespace' href='/ahoang/Nim/commit/compiler/bitsets.nim?h=devel&id=d68181246571de5799059cf6402f1c578cd9421c'>d68181246 ^
e25474154 ^

2df9b442c ^









427490a84 ^
e25474154 ^

d68181246 ^
e25474154 ^


d68181246 ^
e25474154 ^



d68181246 ^
e25474154 ^


d68181246 ^
e25474154 ^

d68181246 ^
e25474154 ^
d68181246 ^

e25474154 ^
d68181246 ^

e25474154 ^
d68181246 ^

e25474154 ^
d68181246 ^



e25474154 ^


d68181246 ^


e25474154 ^

427490a84 ^

c4d7cc3da ^


















427490a84 ^



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
91
92
93
94
95
96
97