- What version of GopherLua are you using? : master (75f4976) and v1.1.1
- What version of Go are you using? : 1.26.2
- What operating system and processor architecture are you using? : darwin/arm64
- What did you do? :
print(select("#", ("abc"):match("(%d+)")))
print(pcall(tonumber, ("abc"):match("(%d+)")))
- What did you expect to see? :
string.match returns nil when there is no match (Lua 5.1 manual: "If it finds one, then match returns the captures from the pattern; otherwise it returns nil"). Lua 5.1.5:
- What did you see instead? :
0
false bad argument #1 to (anonymous) (value expected)
strMatch pushes LNil but returns 0, so no value is returned. Common code such as tonumber(s:match("(%d+)")) fails with "value expected".
string.matchreturnsnilwhen there is no match (Lua 5.1 manual: "If it finds one, then match returns the captures from the pattern; otherwise it returns nil"). Lua 5.1.5:strMatchpushesLNilbut returns 0, so no value is returned. Common code such astonumber(s:match("(%d+)"))fails with "value expected".