go-delve/delve · error
expression %T not implemented
Error message
expression %T not implemented
What it means
Composite literals (struct/slice/map literals like T{...} or []int{1,2}) are only supported by Delve's expression evaluator when debug-pinning (function call injection with pinning) is available. compileAST builds a notimplerr for *ast.CompositeLit and returns it immediately unless the HasDebugPinner flag is set in the compile context. Without a pinner, the evaluator cannot allocate memory for the literal, so it refuses to compile the expression.
Source
Thrown at pkg/proc/evalop/evalcompile.go:427
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{})
}
case *ast.BasicLit:
ctx.pushOp(&PushConst{constant.MakeFromLiteral(node.Value, node.Kind, 0)})
case *ast.CompositeLit:
notimplerr := fmt.Errorf("expression %T not implemented", t)
if ctx.flags&HasDebugPinner == 0 {
return notimplerr
}
dtyp, err := ctx.FindTypeExpr(node.Type)
if err != nil {
return err
}
typ := godwarf.ResolveTypedef(dtyp)
switch typ := typ.(type) {
case *godwarf.StructType:
if !ctx.allowCalls {
return errFuncCallNotAllowedLitAlloc
}
ctx.pushOp(&PushNewFakeVariable{Type: dtyp})
for i, elt := range node.Elts {
ctx.pushOp(&Dup{})View on GitHub (pinned to a23773e6c3)
Solutions
- Avoid composite literals in evaluated expressions; construct values step by step using 'set' on individual fields/elements
- Use function call injection (a call that builds the value) if the backend supports it, e.g. a helper function in the debugged program
- Upgrade/check backend support: pinning works on native backends; on core dumps or gdbserial targets literals cannot be allocated
Example fix
// before
(dlv) print []byte{104, 105}
// after
(dlv) print s // existing []byte variable, or set individual elements
(dlv) set s[0] = 104 Defensive patterns
Strategy: fallback
Validate before calling
// Check for composite literal syntax before evaluating
if strings.Contains(expr, "{") && (strings.Contains(expr, "[]") || strings.Contains(expr, "map[") || strings.Contains(expr, "struct{")) {
// composite literal likely; plan a fallback (variable-based) expression
} Type guard
null
Try / catch
null
Prevention
- Pre-allocate values in program source; debug with existing variables
- On backends without pinning, avoid literals entirely
- Use call injection with a constructor function as a fallback
When it happens
Trigger: Evaluating an expression containing a composite literal (e.g. 'print []int{1,2,3}' or 'set m = map[string]int{}') through an API path that did not enable HasDebugPinner — typically non-set evaluations or backends/targets where call injection pinning is unavailable.
Common situations: Using 'print' on a literal expression on a target/backend that lacks the pinner facility; evaluating composite literals over gdbserial/core backends where allocation isn't possible; older delve versions or restricted environments.
Related errors
- 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
- wrong number of arguments to complex: %d
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/47c22998e8bcbf7d.
Report an issue: GitHub.