title: "attempt to call a nil value" when doing a generic loop
body: <p>I'm getting an error with Lua (standard interprteter) and I can't find the source of the problem. I am trying to create something that resembles an enum from languages like Java, C#, etc. The current code that I have to define the enum standards is this:</p>
  
  <pre><code>enum = {
      new = function (self, ...)
          local o = {};
          setmetatable(o, self);
          self.__index = self;
          for k,v in args do -- THIS LINE IS GIVING THE ERROR
              self[v] = 2^k;
          end
          table.sort(self, function(a,b) if a&gt;b then return true; else return false; end end)
          return o;
      end,
      sum = function (self, ...)
          local s
          for k,v in args do
              s = s+self[v];
          end
      end,
      expand = function (self, number)
          indices = {};
          for k,v in ipairs(self) do
              if v &lt; number then
                  table.append(k);
                  number = number-v;
              end
          end
          return unpack(indices);
      end
  }
  </code></pre>
  
  <p>The error appears in the <code>new</code> function, in the loop statement (not the statement inside it). What can be the cause of this? I'm not "calling" the values, just referencing them.
  I also tried replacing <code>2^k</code> with <code>math.pow(2,k)</code>, so it's not the math, either.
  I run the following code to test the script:</p>
  
  <pre><code>myEnum = enum:new("a","b","c");
  </code></pre>
  
  <p>I should note that the error simply says what is on the title, no variable name or anything.</p>