Guest User

Corner case Lua assignment bug

a guest
Jan 4th, 2012
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.41 KB | None | 0 0
  1. do local a = {}; a[1], a = 1, 2 end
  2. do local a = {}; a[1], a = (function() a = nil end)(), 2 end
  3. do a = {}; a[1] = (function() a = nil end)() end
  4.  
  5. -- uh oh. this one indexes nil
  6. do local a = {}; a[1] = (function() a = nil end)() end -- error!
  7. -- and of course there's nastier examples
  8. do
  9.     local a = {}
  10.     local b = setmetatable({}, { __add = function() a = nil end })
  11.     a[1] = b + 0 -- bang! fails as well
  12. end
Advertisement
Add Comment
Please, Sign In to add comment