Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Fix GetTable, SetTable, RawGet, RawSet if index<0 #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 4 additions & 4 deletions lua/lua.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ func (state *State) SetMetaTableAt(index int) {
// See https://www.lua.org/manual/5.3/manual.html#lua_gettable
func (state *State) GetTable(index int) Type {
var (
key = state.frame().pop()
obj = state.get(index)
key = state.frame().pop()
)
val := state.gettable(obj, key, false)
state.frame().push(val)
Expand All @@ -281,9 +281,9 @@ func (state *State) GetTable(index int) Type {
// See https://www.lua.org/manual/5.3/manual.html#lua_settable
func (state *State) SetTable(index int) {
var (
obj = state.get(index)
val = state.frame().pop()
key = state.frame().pop()
obj = state.get(index)
)
state.settable(obj, key, val, false)
}
Expand Down Expand Up @@ -351,8 +351,8 @@ func (state *State) SetIndex(index int, entry int64) {
// See https://www.lua.org/manual/5.3/manual.html#lua_rawget
func (state *State) RawGet(index int) Type {
var (
key = state.frame().pop()
obj = state.get(index)
key = state.frame().pop()
)
val := state.gettable(obj, key, true)
state.frame().push(val)
Expand All @@ -364,9 +364,9 @@ func (state *State) RawGet(index int) Type {
// See https://www.lua.org/manual/5.3/manual.html#lua_rawset
func (state *State) RawSet(index int) {
var (
obj = state.get(index)
val = state.frame().pop()
key = state.frame().pop()
obj = state.get(index)
)
state.settable(obj, key, val, true)
}
Expand Down