{"record":{"id":"adddf6a796df2701","repo":"go-delve/delve","slug":"can-not-convert-value-of-type-s-to-uint","errorCode":null,"errorMessage":"can not convert value of type %s to uint","messagePattern":"can not convert value of type (.+?) to uint","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/eval.go","lineNumber":2749,"sourceCode":"\t\t\treturn 0, fmt.Errorf(\"can not convert value of type %s to int\", v.DwarfType.String())\n\t\t}\n\t}\n\tn, _ := constant.Int64Val(v.Value)\n\treturn n, nil\n}\n\nfunc (v *Variable) asUint() (uint64, error) {\n\tif v.DwarfType == nil {\n\t\tif v.Value.Kind() != constant.Int {\n\t\t\treturn 0, fmt.Errorf(\"can not convert constant %s to uint\", v.Value)\n\t\t}\n\t} else {\n\t\tv.loadValue(loadSingleValue)\n\t\tif v.Unreadable != nil {\n\t\t\treturn 0, v.Unreadable\n\t\t}\n\t\tif _, ok := v.DwarfType.(*godwarf.UintType); !ok {\n\t\t\treturn 0, fmt.Errorf(\"can not convert value of type %s to uint\", v.DwarfType.String())\n\t\t}\n\t}\n\tn, _ := constant.Uint64Val(v.Value)\n\treturn n, nil\n}\n\ntype typeConvErr struct {\n\tsrcType, dstType godwarf.Type\n}\n\nfunc (err *typeConvErr) Error() string {\n\treturn fmt.Sprintf(\"can not convert value of type %s to %s\", err.srcType.String(), err.dstType.String())\n}\n\nfunc (v *Variable) isType(typ godwarf.Type, kind reflect.Kind) error {\n\tif v.DwarfType != nil {\n\t\tif typ == nil || !sameType(typ, v.RealType) {\n\t\t\treturn &typeConvErr{v.DwarfType, typ}","sourceCodeStart":2731,"sourceCodeEnd":2767,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/eval.go#L2731-L2767","documentation":"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.","triggerScenarios":"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.","commonSituations":"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'.","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"],"exampleFix":"// before\nprint(uint(signedVal))\n// after\nprint(uint64(signedVal))  // or uint64(int64(signedVal)) if truncation semantics needed","handlingStrategy":"validation","validationCode":"// check type before casting: 'whatis myVar' must report a uint* type\nprint(uint64(myVar))","typeGuard":"// only cast when DWARF type is unsigned\n// if whatis(expr) matches /^uint/ then cast else use int64 or float64","tryCatchPattern":null,"preventionTips":["Match cast width/signedness to the variable's DWARF type","Use uintptr for pointer-to-integer conversions","Inspect variable types before writing breakpoint conditions"],"tags":["go","debugger","type-conversion","eval"],"backgroundTag":"invalid-type-conversion","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}