(list []any, index int, val any)
| 297 | } |
| 298 | |
| 299 | func setIndex(list []any, index int, val any) (l2 []any, err error) { |
| 300 | // There are possible index values that are out of range on a target system |
| 301 | // causing a panic. This will catch the panic and return an error instead. |
| 302 | // The value of the index that causes a panic varies from system to system. |
| 303 | defer func() { |
| 304 | if r := recover(); r != nil { |
| 305 | err = fmt.Errorf("error processing index %d: %s", index, r) |
| 306 | } |
| 307 | }() |
| 308 | |
| 309 | if index < 0 { |
| 310 | return list, fmt.Errorf("negative %d index not allowed", index) |
| 311 | } |
| 312 | if index > MaxIndex { |
| 313 | return list, fmt.Errorf("index of %d is greater than maximum supported index of %d", index, MaxIndex) |
| 314 | } |
| 315 | if len(list) <= index { |
| 316 | newlist := make([]any, index+1) |
| 317 | copy(newlist, list) |
| 318 | list = newlist |
| 319 | } |
| 320 | list[index] = val |
| 321 | return list, nil |
| 322 | } |
| 323 | |
| 324 | func (t *parser) keyIndex() (int, error) { |
| 325 | // First, get the key. |
no outgoing calls
searching dependent graphs…