index-range

A list index is not a whole number from 0 up to one less than the size of the list.

run error, shown by synod run.

Lists count from 0, so a list of 3 items has the indexes 0, 1 and 2. item i of xs and set item i of xs to v need a whole number in that range. random.Pick of an empty list has no item to pick and raises the same code.

Example

Run this program to see the diagnostic.

# package main
use std/sim

define main
  set xs to {1s, 2s, 3s}
  sim.StopAt (item 3 of xs)

Diagnostic

failed at 0s: p/main.synod:6:15: error[index-range]: index 3 is out of range for a list of 3 items

Fix

Use an index below the size of the list, counting from 0.

# package main
use std/sim

define main
  set xs to {1s, 2s, 3s}
  sim.StopAt (item 2 of xs)