@@ -119,14 +119,16 @@ function mt:_lookInto(action, topNode, outNode)
119119 return topNode , outNode
120120 end
121121 if self ._mark [action ] then
122- return
122+ return topNode , outNode
123123 end
124124 self ._mark [action ] = true
125125 local top = self ._objs [self ._index ]
126126 if not top then
127127 return topNode , outNode
128128 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
130132 return topNode , outNode
131133 end
132134 local set
@@ -220,6 +222,7 @@ function mt:_lookInto(action, topNode, outNode)
220222 end
221223 if exp .type == ' getlocal'
222224 and exp .node == self ._loc then
225+ -- if x == y then
223226 self :_fastWard (exp .finish , topNode :copy ())
224227 local checkerNode = vm .compileNode (checker )
225228 if action .op .type == ' ==' then
@@ -240,6 +243,7 @@ function mt:_lookInto(action, topNode, outNode)
240243 and exp .args [1 ]
241244 and exp .args [1 ].type == ' getlocal'
242245 and exp .args [1 ].node == self ._loc then
246+ -- if type(x) == 'string' then
243247 self :_fastWard (exp .finish , topNode :copy ())
244248 if action .op .type == ' ==' then
245249 topNode :narrow (checker [1 ])
@@ -252,6 +256,34 @@ function mt:_lookInto(action, topNode, outNode)
252256 outNode :narrow (checker [1 ])
253257 end
254258 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
255287 end
256288 end
257289 elseif action .type == ' call' then
0 commit comments