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
8 changes: 7 additions & 1 deletion tag_methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,17 @@ func (l *State) tagMethodByObject(o value, event tm) value {
}

func (l *State) callTagMethod(f, p1, p2 value) value {
top := l.top
if l.callInfo.isLua() && l.top < l.callInfo.top {
l.top = l.callInfo.top
}
l.push(f)
l.push(p1)
l.push(p2)
l.call(l.top-3, 1, l.callInfo.isLua())
return l.pop()
v := l.pop()
l.top = top
return v
}

func (l *State) callTagMethodV(f, p1, p2, p3 value) {
Expand Down
21 changes: 21 additions & 0 deletions vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,27 @@ func TestVarArgMeta(t *testing.T) {
testString(t, s)
}

func TestConcatWithMetatableIndexInTableConstructor(t *testing.T) {
testString(t, `local meta = {
__index = function(self, key)
return "ASD"
end
}

TEST = {}
setmetatable(TEST, meta)
assert('b ' .. TEST.B .. ' b' == 'b ASD b')

local x = {
'a ' .. TEST.A .. ' a',
'b ' .. TEST.B .. ' b'
}

assert(x[1] == 'a ASD a')
assert(x[2] == 'b ASD b', 'got ' .. tostring(x[2]))
assert('c ' .. TEST.C == 'c ASD')`)
}

func TestCanRemoveNilObjectFromStack(t *testing.T) {
defer func() {
if r := recover(); r != nil {
Expand Down
Loading