summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-03-02 12:23:35 +0100
committerAndreas Rumpf <rumpf_a@web.de>2017-03-02 12:23:35 +0100
commit3e7b04683c7912cc49d05444187ca3bde7bc18aa (patch)
tree7fd4c7c12e0b51f381b81d9c9ce2b4387c5514e8
parentee13c8014bfb6a3100b8e0d3150b755ba36b44e4 (diff)
downloadNim-3e7b04683c7912cc49d05444187ca3bde7bc18aa.tar.gz
make tests green again
-rw-r--r--compiler/semgnrc.nim8
-rw-r--r--compiler/semtempl.nim4
-rw-r--r--compiler/suggest.nim7
-rw-r--r--tools/nimsuggest/tester.nim22
4 files changed, 30 insertions, 11 deletions
diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim
index 9c05ab2f9..47a094f9d 100644
--- a/compiler/semgnrc.nim
+++ b/compiler/semgnrc.nim
@@ -161,6 +161,10 @@ proc addTempDecl(c: PContext; n: PNode; kind: TSymKind) =
 proc semGenericStmt(c: PContext, n: PNode,
                     flags: TSemGenericFlags, ctx: var GenericCtx): PNode =
   result = n
+
+  when defined(nimsuggest):
+    if withinTypeDesc in flags: inc c.inTypeContext
+
   #if gCmd == cmdIdeTools: suggestStmt(c, n)
   semIdeForTemplateOrGenericCheck(n, ctx.cursorInBody)
 
@@ -458,6 +462,10 @@ proc semGenericStmt(c: PContext, n: PNode,
     for i in countup(0, sonsLen(n) - 1):
       result.sons[i] = semGenericStmt(c, n.sons[i], flags, ctx)
 
+  when defined(nimsuggest):
+    if withinTypeDesc in flags: dec c.inTypeContext
+
+
 proc semGenericStmt(c: PContext, n: PNode): PNode =
   var ctx: GenericCtx
   ctx.toMixin = initIntset()
diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim
index d7134402f..f809b6a50 100644
--- a/compiler/semtempl.nim
+++ b/compiler/semtempl.nim
@@ -289,7 +289,11 @@ proc semTemplSomeDecl(c: var TemplCtx, n: PNode, symKind: TSymKind; start=0) =
     if (a.kind != nkIdentDefs) and (a.kind != nkVarTuple): illFormedAst(a)
     checkMinSonsLen(a, 3)
     var L = sonsLen(a)
+    when defined(nimsuggest):
+      inc c.c.inTypeContext
     a.sons[L-2] = semTemplBody(c, a.sons[L-2])
+    when defined(nimsuggest):
+      dec c.c.inTypeContext
     a.sons[L-1] = semTemplBody(c, a.sons[L-1])
     for j in countup(0, L-3):
       addLocalDecl(c, a.sons[j], symKind)
diff --git a/compiler/suggest.nim b/compiler/suggest.nim
index e2aeb414e..41d61c12a 100644
--- a/compiler/suggest.nim
+++ b/compiler/suggest.nim
@@ -161,6 +161,8 @@ proc filterSym(s: PSym; prefix: PNode): bool {.inline.} =
       if n.len > 0:
         result = prefixMatch(s, n[0])
     else: discard
+    if result:
+      echo "indeed a prefix match ", n
   if s.kind != skModule:
     result = prefix.isNil or prefixMatch(s, prefix)
 
@@ -471,7 +473,10 @@ proc suggestExpr*(c: PContext, node: PNode) =
     if n == nil: n = node
     if n.kind == nkDotExpr:
       var obj = safeSemExpr(c, n.sons[0])
-      let prefix = if n.len == 2: n[1] else: nil
+      # it can happen that errnously we have collected the fieldname
+      # of the next line, so we check the 'field' is actually on the same
+      # line as the object to prevent this from happening:
+      let prefix = if n.len == 2 and n[1].info.line == n[0].info.line: n[1] else: nil
       suggestFieldAccess(c, obj, prefix, outputs)
 
       #if optIdeDebug in gGlobalOptions:
diff --git a/tools/nimsuggest/tester.nim b/tools/nimsuggest/tester.nim
index 451af32f5..a80c0b3d7 100644
--- a/tools/nimsuggest/tester.nim
+++ b/tools/nimsuggest/tester.nim
@@ -212,8 +212,8 @@ proc doReport(filename, answer, resp: string; report: var string) =
     var hasDiff = false
     for i in 0..min(resp.len-1, answer.len-1):
       if resp[i] != answer[i]:
-        report.add "\n  Expected:  " & resp.substr(i)
-        report.add "\n  But got:   " & answer.substr(i)
+        report.add "\n  Expected:  " & resp.substr(i, i+200)
+        report.add "\n  But got:   " & answer.substr(i, i+200)
         hasDiff = true
         break
     if not hasDiff:
@@ -233,15 +233,17 @@ proc runEpcTest(filename: string): int =
   let outp = p.outputStream
   let inp = p.inputStream
   var report = ""
-  #var a = newStringOfCap(120)
   try:
     # read the port number:
-    #discard outp.readLine(a)
-    var i = 0
-    while not osproc.hasData(p) and i < 100:
-      os.sleep(50)
-      inc i
-    let a = outp.readAll().strip()
+    when defined(posix):
+      var a = newStringOfCap(120)
+      discard outp.readLine(a)
+    else:
+      var i = 0
+      while not osproc.hasData(p) and i < 100:
+        os.sleep(50)
+        inc i
+      let a = outp.readAll().strip()
     let port = parseInt(a)
     var socket = newSocket()
     socket.connect("localhost", Port(port))
@@ -298,7 +300,7 @@ proc runTest(filename: string): int =
 proc main() =
   var failures = 0
   when false:
-    let x = getAppDir() / "tests/twithin_macro.nim"
+    let x = getAppDir() / "tests/tdot1.nim"
     let xx = expandFilename x
     failures += runEpcTest(xx)
   else:
6b64f800 ^
6b64f800 ^
94ad882e ^
4718a77c ^
6b64f800 ^
a9985c33 ^
4718a77c ^
6b64f800 ^
4718a77c ^

6b64f800 ^

a6517ed8 ^

6b64f800 ^


a6517ed8 ^
6b64f800 ^

a6517ed8 ^
6b64f800 ^









f75c7021 ^
6b64f800 ^



732cf4e7 ^
3c46d5a2 ^



6b64f800 ^




03e72be6 ^
f02ca8df ^
420cb686 ^

6b64f800 ^
53e6c50a ^
880bfb78 ^
6b64f800 ^
8950915a ^

fb7cd3f1 ^



a6517ed8 ^
4718a77c ^
880bfb78 ^
6b64f800 ^




d48cfd0f ^

8950915a ^
d48cfd0f ^


8950915a ^
d48cfd0f ^
8950915a ^






d48cfd0f ^

6b64f800 ^


071afeff ^

6b64f800 ^






a6517ed8 ^

071afeff ^

a6517ed8 ^
071afeff ^


a6517ed8 ^

0828df68 ^
a6517ed8 ^

071afeff ^
a6517ed8 ^
071afeff ^
f75c7021 ^
a6517ed8 ^

071afeff ^
a6517ed8 ^
071afeff ^
0828df68 ^
a6517ed8 ^
071afeff ^










071afeff ^






6b64f800 ^

03e72be6 ^



6b64f800 ^







071afeff ^
d33fa1c5 ^
f3901d90 ^
071afeff ^
94ad882e ^
071afeff ^
94ad882e ^
071afeff ^
94ad882e ^
31338623 ^
f3901d90 ^
d33fa1c5 ^
f3901d90 ^
31338623 ^
071afeff ^



03e72be6 ^
fb7cd3f1 ^







03e72be6 ^


03e72be6 ^
94ad882e ^
420cb686 ^
f02ca8df ^



f02ca8df ^
94ad882e ^
420cb686 ^




f3901d90 ^
94ad882e ^
420cb686 ^
87d5bdb9 ^




bccaa722 ^
94ad882e ^

bccaa722 ^
87d5bdb9 ^
94ad882e ^
bccaa722 ^
87d5bdb9 ^
a6061b9f ^


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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287