go-delve/delve · error
can not convert value of type %s to uint
Error message
can not convert value of type %s to uint
What it means
The unsigned counterpart of error 430: Variable.asUint() loads the value and requires v.DwarfType to be an *godwarf.UintType. If the variable's DWARF type is anything else (signed int, float, string, pointer, struct...), the conversion to uint64 is rejected with this error, which includes the variable's DWARF type name.
Source
Thrown at pkg/proc/eval.go:2749
return 0, fmt.Errorf("can not convert value of type %s to int", v.DwarfType.String())
}
}
n, _ := constant.Int64Val(v.Value)
return n, nil
}
func (v *Variable) asUint() (uint64, error) {
if v.DwarfType == nil {
if v.Value.Kind() != constant.Int {
return 0, fmt.Errorf("can not convert constant %s to uint", v.Value)
}
} else {
v.loadValue(loadSingleValue)
if v.Unreadable != nil {
return 0, v.Unreadable
}
if _, ok := v.DwarfType.(*godwarf.UintType); !ok {
return 0, fmt.Errorf("can not convert value of type %s to uint", v.DwarfType.String())
}
}
n, _ := constant.Uint64Val(v.Value)
return n, nil
}
type typeConvErr struct {
srcType, dstType godwarf.Type
}
func (err *typeConvErr) Error() string {
return fmt.Sprintf("can not convert value of type %s to %s", err.srcType.String(), err.dstType.String())
}
func (v *Variable) isType(typ godwarf.Type, kind reflect.Kind) error {
if v.DwarfType != nil {
if typ == nil || !sameType(typ, v.RealType) {
return &typeConvErr{v.DwarfType, typ}View on GitHub (pinned to a23773e6c3)
Solutions
- Cast to the matching type: int64(...) for signed values, or convert through the variable's actual type first
- Use uintptr(ptr) for pointer-to-integer conversions instead of uint(ptr)
- Run 'whatis <expr>' in the debugger to confirm the DWARF type before casting
- If the type appears wrong, check that the binary was built with complete DWARF info
Example fix
// before print(uint(signedVal)) // after print(uint64(signedVal)) // or uint64(int64(signedVal)) if truncation semantics needed
Defensive patterns
Strategy: validation
Validate before calling
// check type before casting: 'whatis myVar' must report a uint* type print(uint64(myVar))
Type guard
// only cast when DWARF type is unsigned // if whatis(expr) matches /^uint/ then cast else use int64 or float64
Prevention
- Match cast width/signedness to the variable's DWARF type
- Use uintptr for pointer-to-integer conversions
- Inspect variable types before writing breakpoint conditions
When it happens
Trigger: Variable.asUint() with a non-nil, non-UintType DwarfType — e.g. evaluating uint(signedIntVar), uint(floatVar), uint(ptrVar) in debugger expressions, array indexing, or internal conversion paths in eval.go.
Common situations: Casting an int or float variable to uint in a breakpoint condition; pointer-to-integer casts in watch expressions; user assumptions that 'everything numeric is convertible'.
Related errors
- can not convert value of type %s to int
- can not convert constant %s to uint
- can not convert %s constant to %s
- %s has no member %s
- can not convert value of type %s to %s: %v
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/adddf6a796df2701.
Report an issue: GitHub.