Search code examples
luaupvalue

What is the meaning of 'attempt to index upvalue'


I am taking my first steps programming in Lua and get this error when I run my script:

attempt to index upvalue 'base' (a function value)

It's probably due to something very basic that I haven't grasped yet, but I can't find any good information about it when googling. Could someone explain to me what it means?


Solution

  • In this case it looks base is a function, but you're trying to index it like a table (eg. base[5] or base.somefield).

    The 'upvalue' part is just telling you what kind of variable base is, in this case an upvalue (aka external local variable).