@@ -58,7 +58,7 @@ return function(META--[[#: any]])
5858 }
5959 push_break_state (self , break_state )
6060 self :PushScope (loop_scope )
61- self :ApplyMutationsAfterStatement (scope , true , scope :GetTrackedUpvalues (), scope : GetTrackedTables ())
61+ self :ApplyMutationsAfterStatement (scope , true , scope :GetTrackedNarrowings ())
6262 self :PopScope ()
6363 end
6464
@@ -256,34 +256,27 @@ return function(META--[[#: any]])
256256
257257 if assert_expression and assert_expression :IsTruthy () then
258258 -- track the assertion expression
259- local upvalues
260- local tracked = self :GetTrackedUpvalues (nil , frame .scope )
261-
262- if tracked [1 ] then
263- upvalues = {}
264-
265- for _ , a in ipairs (tracked ) do
266- for _ , b in ipairs (self :GetTrackedUpvalues ()) do
267- if a .upvalue == b .upvalue then table_insert (upvalues , a ) end
268- end
269- end
270- end
271-
272- local tables
273- local tracked = self :GetTrackedTables (nil , frame .scope )
274-
275- if tracked [1 ] then
276- tables = {}
277-
278- for _ , a in ipairs (tracked ) do
279- for _ , b in ipairs (self :GetTrackedTables ()) do
280- if a .obj == b .obj then table_insert (tables , a ) end
259+ local tracked_objects
260+ local tracked_from_scope = self :GetTrackedObjects (nil , frame .scope )
261+
262+ if tracked_from_scope [1 ] then
263+ local current_tracked = self :GetTrackedObjects ()
264+ tracked_objects = {}
265+
266+ for _ , a in ipairs (tracked_from_scope ) do
267+ for _ , b in ipairs (current_tracked ) do
268+ if
269+ (a .kind == " upvalue" and b .kind == " upvalue" and a .upvalue == b .upvalue ) or
270+ (a .kind == " table" and b .kind == " table" and a .obj == b .obj )
271+ then
272+ table_insert (tracked_objects , a )
273+ end
281274 end
282275 end
283276 end
284277
285278 self :PushScope (function_scope )
286- self :ApplyMutationsAfterStatement (frame .scope , false , upvalues , tables )
279+ self :ApplyMutationsAfterStatement (frame .scope , false , tracked_objects )
287280 self :PopScope ()
288281 return
289282 end
@@ -292,8 +285,7 @@ return function(META--[[#: any]])
292285 self :ApplyMutationsAfterStatement (
293286 frame .scope ,
294287 true ,
295- frame .scope :GetTrackedUpvalues (),
296- frame .scope :GetTrackedTables ()
288+ frame .scope :GetTrackedNarrowings ()
297289 )
298290 self :PopScope ()
299291 end
@@ -323,9 +315,9 @@ return function(META--[[#: any]])
323315 end
324316
325317 local scope = self :GetScope ()
326- local u , t = self :GetTrackedUpvalues (old ), self : GetTrackedTables ( )
318+ local tracked = self :GetTrackedObjects (old )
327319 self :PushScope (self :GetScope ():GetNearestFunctionScope ())
328- self :ApplyMutationsAfterStatement (scope , false , u , t )
320+ self :ApplyMutationsAfterStatement (scope , false , tracked )
329321 self :PopScope ()
330322
331323 if not no_report then
@@ -391,7 +383,7 @@ return function(META--[[#: any]])
391383 end
392384
393385 self :PushScope (function_scope )
394- self :ApplyMutationsAfterStatement (scope , true , scope :GetTrackedUpvalues (), scope : GetTrackedTables ())
386+ self :ApplyMutationsAfterStatement (scope , true , scope :GetTrackedNarrowings ())
395387 self :PopScope ()
396388 end
397389
0 commit comments