diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-08-17 17:38:51 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-08-17 17:38:51 -0300 |
commit | 8a008a20579dd6818cb770147c8765b72eb2acfe (patch) | |
tree | 76b08f24056a2305417eac3ccb69926d53483ca8 | |
parent | 89b59eee7386379e87200a86215fc6de91e49036 (diff) | |
download | lua-8a008a20579dd6818cb770147c8765b72eb2acfe.tar.gz lua-8a008a20579dd6818cb770147c8765b72eb2acfe.tar.bz2 lua-8a008a20579dd6818cb770147c8765b72eb2acfe.zip |
bug: __newindex metamethod may not work if metatable is its own
metatable.
-rw-r--r-- | bugs | 31 |
1 files changed, 29 insertions, 2 deletions
@@ -1880,8 +1880,8 @@ patch = [[ | |||
1880 | +++ lundump.c 2008/04/04 19:51:41 2.7.1.4 | 1880 | +++ lundump.c 2008/04/04 19:51:41 2.7.1.4 |
1881 | @@ -1,5 +1,5 @@ | 1881 | @@ -1,5 +1,5 @@ |
1882 | /* | 1882 | /* |
1883 | -** $Id: bugs,v 1.108 2010/05/14 15:34:57 roberto Exp roberto $ | 1883 | -** $Id: bugs,v 1.109 2011/01/31 14:52:32 roberto Exp roberto $ |
1884 | +** $Id: bugs,v 1.108 2010/05/14 15:34:57 roberto Exp roberto $ | 1884 | +** $Id: bugs,v 1.109 2011/01/31 14:52:32 roberto Exp roberto $ |
1885 | ** load precompiled Lua chunks | 1885 | ** load precompiled Lua chunks |
1886 | ** See Copyright Notice in lua.h | 1886 | ** See Copyright Notice in lua.h |
1887 | */ | 1887 | */ |
@@ -2359,3 +2359,30 @@ patch = [[ | |||
2359 | break; | 2359 | break; |
2360 | ]] | 2360 | ]] |
2361 | } | 2361 | } |
2362 | |||
2363 | Bug{ | ||
2364 | what = [[__newindex metamethod may not work if metatable is its own | ||
2365 | metatable]], | ||
2366 | report = [[Cuero Bugot, 2011/08/09]], | ||
2367 | since = [[5.1]], | ||
2368 | example = [[ | ||
2369 | meta={} | ||
2370 | setmetatable(meta, meta) | ||
2371 | meta.__newindex = function(t, key, value) print("set") end | ||
2372 | o = setmetatable({}, meta) | ||
2373 | o.x = 10 -- should print 'set' | ||
2374 | ]], | ||
2375 | patch = [[ | ||
2376 | --- lvm.c 2009/07/01 21:10:33 2.63.1.4 | ||
2377 | +++ lvm.c 2011/08/17 20:36:28 | ||
2378 | @@ -142,6 +142,7 @@ | ||
2379 | if (!ttisnil(oldval) || /* result is no nil? */ | ||
2380 | (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */ | ||
2381 | setobj2t(L, oldval, val); | ||
2382 | + h->flags = 0; | ||
2383 | luaC_barriert(L, h, val); | ||
2384 | return; | ||
2385 | } | ||
2386 | ]] | ||
2387 | } | ||
2388 | |||