go-delve/delve · error
%d is out of range
Error message
%d is out of range
What it means
`Term.removeDisplay` deletes an entry from the term's list of `display` expressions. The index `n` must be a valid zero-based index into `t.displays`; if it is negative or past the end, the function returns '%d is out of range'. Note that removing the last non-empty entry shrinks the slice, so indices of previously-removed-but-trailing entries become invalid.
Source
Thrown at pkg/terminal/terminal.go:640
full := proc.LoadFullValue()
r := *api.LoadConfigFromProc(&full)
if t.conf != nil && t.conf.MaxStringLen != nil {
r.MaxStringLen = *t.conf.MaxStringLen
}
if t.conf != nil && t.conf.MaxArrayValues != nil {
r.MaxArrayValues = *t.conf.MaxArrayValues
}
if t.conf != nil && t.conf.MaxVariableRecurse != nil {
r.MaxVariableRecurse = *t.conf.MaxVariableRecurse
}
return r
}
func (t *Term) removeDisplay(n int) error {
if n < 0 || n >= len(t.displays) {
return fmt.Errorf("%d is out of range", n)
}
t.displays[n] = displayEntry{"", ""}
for i := len(t.displays) - 1; i >= 0; i-- {
if t.displays[i].expr != "" {
t.displays = t.displays[:i+1]
return nil
}
}
t.displays = t.displays[:0]
return nil
}
func (t *Term) addDisplay(expr, fmtstr string) {
t.displays = append(t.displays, displayEntry{expr: expr, fmtstr: fmtstr})
}
// rawStringFlag returns the PrettyRawString flag if the config enables it.
func (t *Term) rawStringFlag() api.PrettyFlags {View on GitHub (pinned to a23773e6c3)
Solutions
- Run `display` with no arguments to list existing displays and their valid indices, then retry with one of those
- Use an index between 0 and len(displays)-1
- Remove all displays with `display -r *` if you want to clear them instead of guessing indices
Example fix
# before display -r 5 # after # list first, then remove a valid index display display -r 2
Defensive patterns
Strategy: validation
Validate before calling
// before calling removeDisplay / `display -r n`
func validDisplayIndex(n, len int) bool { return n >= 0 && n < len } Prevention
- List displays first (run `display` with no args) and use only listed indices
- Remember indices are 0-based and the list compacts after removals
- After any removal, refetch the list rather than reusing cached indices
When it happens
Trigger: Running the terminal `display -r <index>` command with an index that does not exist (e.g. `display -r 5` when fewer than 6 displays are defined) or a negative index.
Common situations: Users referring to display numbers from earlier output after some displays were removed; off-by-one confusion (thinking displays are numbered from 1); scripts replaying stale display indices.
Related errors
- %q is not a number
- unrecognized option %q
- index out of bounds
- command not available
- unknown config parameter
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/417bb694916cd574.
Report an issue: GitHub.