@@ -119,14 +119,16 @@ function mt:_lookInto(action, topNode, outNode)
119
119
return topNode , outNode
120
120
end
121
121
if self ._mark [action ] then
122
- return
122
+ return topNode , outNode
123
123
end
124
124
self ._mark [action ] = true
125
125
local top = self ._objs [self ._index ]
126
126
if not top then
127
127
return topNode , outNode
128
128
end
129
- if not guide .isInRange (action , top .finish ) then
129
+ if not guide .isInRange (action , top .finish )
130
+ -- trick for `local tp = type(x);if tp == 'string' then`
131
+ and action .type ~= ' binary' then
130
132
return topNode , outNode
131
133
end
132
134
local set
@@ -220,6 +222,7 @@ function mt:_lookInto(action, topNode, outNode)
220
222
end
221
223
if exp .type == ' getlocal'
222
224
and exp .node == self ._loc then
225
+ -- if x == y then
223
226
self :_fastWard (exp .finish , topNode :copy ())
224
227
local checkerNode = vm .compileNode (checker )
225
228
if action .op .type == ' ==' then
@@ -240,6 +243,7 @@ function mt:_lookInto(action, topNode, outNode)
240
243
and exp .args [1 ]
241
244
and exp .args [1 ].type == ' getlocal'
242
245
and exp .args [1 ].node == self ._loc then
246
+ -- if type(x) == 'string' then
243
247
self :_fastWard (exp .finish , topNode :copy ())
244
248
if action .op .type == ' ==' then
245
249
topNode :narrow (checker [1 ])
@@ -252,6 +256,34 @@ function mt:_lookInto(action, topNode, outNode)
252
256
outNode :narrow (checker [1 ])
253
257
end
254
258
end
259
+ elseif exp .type == ' getlocal'
260
+ and checker .type == ' string' then
261
+ local nodeValue = vm .getObjectValue (exp .node )
262
+ if nodeValue
263
+ and nodeValue .type == ' select'
264
+ and nodeValue .sindex == 1 then
265
+ local call = nodeValue .vararg
266
+ if call
267
+ and call .type == ' call'
268
+ and call .node .special == ' type'
269
+ and call .args
270
+ and call .args [1 ]
271
+ and call .args [1 ].type == ' getlocal'
272
+ and call .args [1 ].node == self ._loc then
273
+ -- `local tp = type(x);if tp == 'string' then`
274
+ if action .op .type == ' ==' then
275
+ topNode :narrow (checker [1 ])
276
+ if outNode then
277
+ outNode :remove (checker [1 ])
278
+ end
279
+ else
280
+ topNode :remove (checker [1 ])
281
+ if outNode then
282
+ outNode :narrow (checker [1 ])
283
+ end
284
+ end
285
+ end
286
+ end
255
287
end
256
288
end
257
289
elseif action .type == ' call' then
0 commit comments