Skip to content

Function at line XXX has more than NNN upvalues #19

@Unisay

Description

@Unisay

Upvalues are closures over an external local variable, for example:

function newCounter ()
  local i = 0
  return function () -- closure
    -- `i` is an "upvalue" because it is external relative to the closure 
    -- and is local to "newCounter"
    i = i + 1 
      return i
    end
end

It looks like Lua v.5.1 has the limit on a maximum number of upvalues set to 60;
Newer versions have it set to 255

This is a problem because pslua produces a chain of nested functions which has more than 60 upvalues (and quite possibly more than 255).

One example when it happens is when Effect expressions are composed

return Init_I_discard(function(..) ... 
  -- could be a big closure containing the rest of computation containing many 
  -- references to top level local variable definitions.
  return Init_I_discard(function(..) ...
    return Init_I_discard(function(..) ...

Related:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions