Skip to content

Commit e7d59e9

Browse files
committed
Fix State.stackIndex for negative indices
1 parent aa16730 commit e7d59e9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

internal/mylua/lua.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (l *State) stackIndex(idx int) (int, error) {
130130
if idx < -l.Top() {
131131
return -1, fmt.Errorf("invalid index %d (top = %d)", idx, l.Top())
132132
}
133-
return l.frame().registerStart() - idx - 1, nil
133+
return len(l.stack) + idx, nil
134134
}
135135
i := l.frame().registerStart() + idx - 1
136136
if i >= cap(l.stack) {

0 commit comments

Comments
 (0)