Skip to content
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
5 changes: 4 additions & 1 deletion value.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,10 @@ func (arr *valueArray) index(i *interpreter, index int) (value, error) {
if 0 <= index && index < arr.length() {
return i.evaluatePV(arr.elements[index])
}
return nil, i.Error(fmt.Sprintf("Index %d out of bounds, not within [0, %v)", index, arr.length()))
if -arr.length() <= index && index < 0 {
return i.evaluatePV(arr.elements[index + arr.length()])
}
return nil, i.Error(fmt.Sprintf("Index %d out of bounds, not within [%v, %v)", index, -arr.length(), arr.length()))
}

func (arr *valueArray) length() int {
Expand Down