Skip to content

Commit

Permalink
fix: fix bug of failing to update member of object
Browse files Browse the repository at this point in the history
  • Loading branch information
gufeijun committed Jun 11, 2022
1 parent 24b95df commit b6b25e1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions vm/types/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ func (obj *Object) Set(k, v interface{}) {
obj.Map[k] = v
return
}
for i := range obj.Array {
if obj.Array[i].Key == k {
obj.Array[i].Val = v
return
}
}
if len(obj.Array) < MaxArrayCap {
obj.Array = append(obj.Array, KV{k, v})
return
Expand Down

0 comments on commit b6b25e1

Please sign in to comment.