[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Yielding across metamethods with Lua 5.2
- From: Ignacio Burgueño <ignaciob@...>
- Date: Tue, 12 Jan 2010 17:02:06 -0200
The following code won't work on Lua 5.1:
local env = setmetatable({}, {
__index = function()
coroutine.yield("bar")
end
})
local f = coroutine.wrap(function()
local var = env.foo
end)
f()
-- fails with this message
lua5.1: pcall.lua:11: attempt to yield across metamethod/C-call boundary
stack traceback:
[C]: in function 'f'
pcall.lua:11: in main chunk
[C]: ?
While it works fine with Lua 5.2.0-work1
However, the following code:
local env = setmetatable({}, {
__index = function()
coroutine.yield("bar")
end
})
local f = coroutine.wrap(function()
local var = env.foo
end)
f()
local var = env.foo
gives this error with Lua 5.2.0-work1
lua5.2: attempt to yield across metamethod/C-call boundary
stack traceback:
[C]: in function 'yield'
pcall.lua:3: in function '__index'
pcall.lua:13: in main chunk
[C]: in ?
It's obvious that my code is wrong since I'm yielding, but I'm not
within a coroutine. Is the error message misleading or I'm missing
something?
Regards
Ignacio