Skip to content

Commit

Permalink
Fix ToString bugs in lua package
Browse files Browse the repository at this point in the history
  • Loading branch information
zombiezen committed Jan 13, 2025
1 parent 3a53411 commit d1cd5f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/lua/auxlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func ToString(l *State, idx int) (string, sets.Set[string], error) {
l.Pop(1)
return "", nil, fmt.Errorf("lua: '__tostring' must return a string")
}
s, _ := l.ToString(idx)
sctx := l.StringContext(idx)
s, _ := l.ToString(-1)
sctx := l.StringContext(-1)
l.Pop(1)
return s, sctx, nil
}
Expand Down
5 changes: 3 additions & 2 deletions internal/lua/lua.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,9 @@ func (l *State) ToString(idx int) (s string, ok bool) {
case stringValue:
return v.s, true
case valueStringer:
*p = v.stringValue()
return s, true
sv := v.stringValue()
*p = sv
return sv.s, true
default:
return "", false
}
Expand Down

0 comments on commit d1cd5f2

Please sign in to comment.