@@ -3548,7 +3548,22 @@ local function parseFor()
3548
3548
LocalCount = LocalCount + forStateVars
3549
3549
if name then
3550
3550
--- @cast name parser.object
3551
- local loc = createLocal (name )
3551
+ -- In Lua 5.5, for loop variables are treated as constants
3552
+ local attrs
3553
+ if State .version == ' Lua 5.5' then
3554
+ attrs = {
3555
+ type = ' localattrs' ,
3556
+ [1 ] = {
3557
+ type = ' localattr' ,
3558
+ start = name .start ,
3559
+ finish = name .finish ,
3560
+ parent = nil , -- will be set by createLocal
3561
+ [1 ] = ' const' ,
3562
+ }
3563
+ }
3564
+ attrs [1 ].parent = attrs
3565
+ end
3566
+ local loc = createLocal (name , attrs )
3552
3567
loc .parent = action
3553
3568
action .finish = name .finish
3554
3569
action .bstart = action .finish
@@ -3653,7 +3668,22 @@ local function parseFor()
3653
3668
for i = 1 , # list do
3654
3669
local obj = list [i ]
3655
3670
--- @cast obj parser.object
3656
- local loc = createLocal (obj )
3671
+ -- In Lua 5.5, for loop variables are treated as constants
3672
+ local attrs
3673
+ if State .version == ' Lua 5.5' then
3674
+ attrs = {
3675
+ type = ' localattrs' ,
3676
+ [1 ] = {
3677
+ type = ' localattr' ,
3678
+ start = obj .start ,
3679
+ finish = obj .finish ,
3680
+ parent = nil , -- will be set by createLocal
3681
+ [1 ] = ' const' ,
3682
+ }
3683
+ }
3684
+ attrs [1 ].parent = attrs
3685
+ end
3686
+ local loc = createLocal (obj , attrs )
3657
3687
loc .parent = action
3658
3688
loc .effect = action .finish
3659
3689
end
0 commit comments