title: Lua metamethod __newindex: "this event happens when table is not a table"?
body: <p>The Lua 5.3 Reference Manual (in this <a href="http://www.lua.org/manual/5.3/manual.html#2.4" rel="nofollow">part</a>, scroll down) says:</p>
  
  <blockquote>
    <p>__newindex: The indexing assignment table[key] = value. Like the index event, this event happens when table is not a table or when key is not present in table. The metamethod is looked up in table.</p>
  </blockquote>
  
  <p>However I don't understand that the metamethod __newindex happens when table is not a table. What does that mean? I did try to re-assign a local with <code>nil</code>, but it didn't work (yes, I know it doesn't make sense to re-assign the table, but this would help it to be garbage-collected).</p>
  
  <pre><code>local v = {};
  
  setmetatable(v, {
      __newindex = function(t,k,v)
          print("Aaahhh...!");
      end
  });
  
  v = nil;
  </code></pre>
  
  <p>I'm using this <a href="https://www.tutorialspoint.com/lua/try_lua.php" rel="nofollow">online compiler</a> to test it.</p>