Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions _glua-tests/strings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ assert(ret1 == 1)
assert(ret2 == 3)
assert(ret3 == "aaa")
assert(ret4 == 4)

-- issue #543: string.match returns nil when there is no match
assert(select("#", ("abc"):match("(%d+)")) == 1)
assert(("abc"):match("(%d+)") == nil)
assert(tonumber(("abc"):match("(%d+)")) == nil)
assert(select("#", string.match("abc", "%d")) == 1)
2 changes: 1 addition & 1 deletion stringlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func strMatch(L *LState) int {
}
if len(mds) == 0 {
L.Push(LNil)
return 0
return 1
}
md := mds[0]
nsubs := md.CaptureLength() / 2
Expand Down