gopher-lua icon indicating copy to clipboard operation
gopher-lua copied to clipboard

Incorrect behavior for string.gmatch

Open zyedidia opened this issue 7 months ago • 0 comments

Gopher Lua version: 9d7d921 Go version: 1.21.0

Ran the following file:

local x = string.gmatch("asdf", "a")
print(x())
$ lua5.1 test.lua
a
$ glua test.lua
test.lua:2: bad argument #1 to x (userdata expected, got nil)
stack traceback:
        [G]: in function 'x'
        test.lua:2: in main chunk
        [G]: ?

It seems like string.gmatch produces a closure that expects some internal userdata. Thanks for your help!

zyedidia avatar Nov 07 '23 05:11 zyedidia