File tree Expand file tree Collapse file tree 2 files changed +247
-3
lines changed Expand file tree Collapse file tree 2 files changed +247
-3
lines changed Original file line number Diff line number Diff line change @@ -12,9 +12,7 @@ return function (uri, callback)
12
12
end
13
13
--- @async
14
14
guide .eachSourceType (state .ast , ' call' , function (source )
15
- local parent = source .parent
16
- if parent .type ~= ' function'
17
- and parent .type ~= ' main' then
15
+ if not guide .isBlockType (source .parent ) then
18
16
return
19
17
end
20
18
await .delay ()
Original file line number Diff line number Diff line change 15
15
16
16
X = f()
17
17
]]
18
+
19
+ TEST [[
20
+ ---@nodiscard
21
+ local function f()
22
+ return 1
23
+ end
24
+
25
+ for i = 1, 2 do
26
+ <!f()!>
27
+ end
28
+ ]]
29
+
30
+ TEST [[
31
+ ---@nodiscard
32
+ local function f()
33
+ return 1
34
+ end
35
+
36
+ for i = 1, 2 do
37
+ local v = f()
38
+ end
39
+ ]]
40
+
41
+ TEST [[
42
+ ---@nodiscard
43
+ local function f()
44
+ return 1
45
+ end
46
+
47
+ while true do
48
+ <!f()!>
49
+ break
50
+ end
51
+ ]]
52
+
53
+ TEST [[
54
+ ---@nodiscard
55
+ local function f()
56
+ return 1
57
+ end
58
+
59
+ while true do
60
+ local v = f()
61
+ break
62
+ end
63
+ ]]
64
+
65
+ TEST [[
66
+ ---@nodiscard
67
+ local function f()
68
+ return 1
69
+ end
70
+
71
+ repeat
72
+ <!f()!>
73
+ break
74
+ until true
75
+ ]]
76
+
77
+ TEST [[
78
+ ---@nodiscard
79
+ local function f()
80
+ return 1
81
+ end
82
+
83
+ repeat
84
+ local v = f()
85
+ break
86
+ until true
87
+ ]]
88
+
89
+ TEST [[
90
+ ---@nodiscard
91
+ local function f()
92
+ return 1
93
+ end
94
+
95
+ for index, value in ipairs({}) do
96
+ <!f()!>
97
+ end
98
+ ]]
99
+
100
+ TEST [[
101
+ ---@nodiscard
102
+ local function f()
103
+ return 1
104
+ end
105
+
106
+ for index, value in ipairs({}) do
107
+ local v = f()
108
+ end
109
+ ]]
110
+
111
+ TEST [[
112
+ ---@nodiscard
113
+ local function f()
114
+ return 1
115
+ end
116
+
117
+ if 1 == 1 then
118
+ <!f()!>
119
+ end
120
+ ]]
121
+
122
+ TEST [[
123
+ ---@nodiscard
124
+ local function f()
125
+ return 1
126
+ end
127
+
128
+ if 1 == 1 then
129
+ local v = f()
130
+ end
131
+ ]]
132
+
133
+ TEST [[
134
+ ---@nodiscard
135
+ local function f()
136
+ return 1
137
+ end
138
+
139
+ if 1 == 1 then
140
+ local v = f()
141
+ else
142
+ <!f()!>
143
+ end
144
+ ]]
145
+
146
+ TEST [[
147
+ ---@nodiscard
148
+ local function f()
149
+ return 1
150
+ end
151
+
152
+ if 1 == 1 then
153
+ local v = f()
154
+ else
155
+ local v = f()
156
+ end
157
+ ]]
158
+
159
+ TEST [[
160
+ ---@nodiscard
161
+ local function f()
162
+ return 1
163
+ end
164
+
165
+ if 1 == 1 then
166
+ local v = f()
167
+ elseif 1 == 2 then
168
+ <!f()!>
169
+ else
170
+ local v = f()
171
+ end
172
+ ]]
173
+
174
+ TEST [[
175
+ ---@nodiscard
176
+ local function f()
177
+ return 1
178
+ end
179
+
180
+ if 1 == 1 then
181
+ local v = f()
182
+ elseif 1 == 2 then
183
+ local v = f()
184
+ else
185
+ local v = f()
186
+ end
187
+ ]]
188
+
189
+ TEST [[
190
+ ---@nodiscard
191
+ local function f()
192
+ return 1
193
+ end
194
+
195
+ local function bar(callback)
196
+ end
197
+
198
+ bar(function ()
199
+ <!f()!>
200
+ end)
201
+ ]]
202
+
203
+ TEST [[
204
+ ---@nodiscard
205
+ local function f()
206
+ return 1
207
+ end
208
+
209
+ local function bar(callback)
210
+ end
211
+
212
+ bar(function ()
213
+ local v = f()
214
+ end)
215
+ ]]
216
+
217
+ TEST [[
218
+ ---@nodiscard
219
+ local function f()
220
+ return 1
221
+ end
222
+
223
+ do
224
+ <!f()!>
225
+ end
226
+ ]]
227
+
228
+ TEST [[
229
+ ---@nodiscard
230
+ local function f()
231
+ return 1
232
+ end
233
+
234
+ do
235
+ local v = f()
236
+ end
237
+ ]]
238
+
239
+ TEST [[
240
+ ---@nodiscard
241
+ local function f()
242
+ return 2
243
+ end
244
+
245
+ for i = 1, f() do
246
+ end
247
+ ]]
248
+
249
+ TEST [[
250
+ ---@nodiscard
251
+ local function list_iter(t)
252
+ local i = 0
253
+ local n = #t
254
+ return function ()
255
+ i = i + 1
256
+ if i <= n then return t[i] end
257
+ end
258
+ end
259
+
260
+ local t = {10, 20, 30}
261
+ for element in list_iter(t) do
262
+ end
263
+ ]]
You can’t perform that action at this time.
0 commit comments