local key
local val
key = buffer.readu8(incoming_buff, read(1))
val = {}
for _ = 1, buffer.readu16(incoming_buff, read(2)) do
local key
local val
key = buffer.readu8(incoming_buff, read(1))
val = buffer.readu8(incoming_buff, read(1)) == 1 -- shadows the `val` table
val[key] = val -- errors because `val` is now a boolean instead of the table
end
Describe the bug
Zap de-serialization will shadow variables and try to use the value of the variable before it was shadowed
Reproduction
https://zap.redblox.dev/playground.html?code=ZXZlbnQgZXhhbXBsZSA9IHsNCiAgICBmcm9tOiBTZXJ2ZXIsDQogICAgdHlwZTogUmVsaWFibGUsDQogICAgY2FsbDogU2luZ2xlU3luYywNCiAgICBkYXRhOiBtYXAgeyBbdThdOiBtYXAgeyBbdThdOiBib29sZWFuIH0gfQ0KfQ0K
If you look at the client you will see: