asar icon indicating copy to clipboard operation
asar copied to clipboard

ban fully-numeric variable names as `for` bounds

Open trillllian opened this issue 6 months ago • 1 comments
trafficstars

for !i = 1..2
endfor

is legal if the define !i already exists and contains a number, as this will expand to for 0 = 1..2, and !0 is a legal define name. (and since !i exists, using it inside the loop will use the old value for each iteration, instead of throwing an error.)

this can be quite a nasty footgun, so i think we should ban fully-numeric for loop variables, even if that's less consistent.

trillllian avatar May 08 '25 12:05 trillllian

I would vote for printing a warning instead. Possibly in all cases, but that can be debated. I think a warning keeps consistency but gives the user enough feedback to catch mistakes.

p4plus2 avatar May 08 '25 18:05 p4plus2