Add a warning when using a key with the same variable name

I lost 20 minutes of dev time because when using a variable as a dictionary index, you need to put it in brackets otherwise it will create a string

local key  = "key"
local tab = {key = true} --tab[key] = nil, tab["key"] = true
local tab = {[key] = true} --tab[key] = true (expected), tab["key"] = nil

On the third line in this image, Key should be underlined because there is a variable also named Key, a developer would more than likely be using the variable instead of a string with the same name
image

3 Likes