go-delve/delve · error
operator %s not supported
Error message
operator %s not supported
What it means
Delve's expression compiler rejects the increment, decrement, and channel-receive operators because they mutate state or interact with channels, which the debugger's expression evaluator (a read-only side-effect-free evaluator) cannot support. When compiling an *ast.BinaryExpr whose Op is token.INC, token.DEC, or token.ARROW, compileAST returns this error instead of generating ops. It is a hard limitation of the evaluator, not a bug.
Source
Thrown at pkg/proc/evalop/evalcompile.go:404
return ctx.compileReslice(node)
case *ast.StarExpr:
// pointer dereferencing *<expression>
return ctx.compileUnary(node.X, &PointerDeref{node})
case *ast.UnaryExpr:
// The unary operators we support are +, - and & (note that unary * is parsed as ast.StarExpr)
switch node.Op {
case token.AND:
return ctx.compileUnary(node.X, &AddrOf{node})
default:
return ctx.compileUnary(node.X, &Unary{node})
}
case *ast.BinaryExpr:
switch node.Op {
case token.INC, token.DEC, token.ARROW:
return fmt.Errorf("operator %s not supported", node.Op.String())
}
// short circuits logical operators
var sop *Jump
switch node.Op {
case token.LAND:
sop = &Jump{When: JumpIfFalse, Node: node.X}
case token.LOR:
sop = &Jump{When: JumpIfTrue, Node: node.X}
}
err := ctx.compileBinary(node.X, node.Y, sop, &Binary{node})
if err != nil {
return err
}
if sop != nil {
sop.Target = len(ctx.ops)
ctx.pushOp(&BoolToConst{})
}
View on GitHub (pinned to a23773e6c3)
Solutions
- Remove the increment/decrement/receive operator and use the equivalent expression instead, e.g. 'print i' then 'set i = i + 1'
- For channel receive, step into or over the receive in code, or read the channel's internals via its fields instead of '<-ch'
- If the expression comes from an IDE watch/config, edit the watch to a pure read expression
Example fix
// before (dlv REPL) (dlv) set i = i++ // after (dlv) set i = i + 1
Defensive patterns
Strategy: validation
Validate before calling
// Before submitting the expression, reject mutating/channel operators
func hasUnsupportedOp(src string) bool {
for _, bad := range []string{"++", "--", "<-"} {
if strings.Contains(src, bad) { return true }
}
return false
}
if hasUnsupportedOp(expr) { /* rewrite expr before eval */ } Type guard
null
Try / catch
null
Prevention
- Use only side-effect-free read expressions in print/watch
- Replace i++ with set i = i + 1
- Never use <-ch in debugger expressions; observe channel state via fields
When it happens
Trigger: Evaluating any expression via dlv eval/print/set that contains 'x++', 'x--', or '<-ch' (the AST represents these in a BinaryExpr position during compilation). Also reached when a Set expression or a call-injection argument contains these operators.
Common situations: Typing 'print i++' at the (dlv) prompt out of habit from C/Java; trying to receive from a channel with 'print <-ch' to inspect a value; IDE watch expressions that auto-increment; converting debugging sessions from gdb (which supports some of these) to delve.
Related errors
- operations on non-finite floats not implemented
- shift count must not be negative
- invalid argument %s (type %s) for cap
- wrong number of arguments to len: %d
- invalid argument %s (type %s) for len
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/f0b5bb05dbd42d01.
Report an issue: GitHub.