{"record":{"id":"9d17f571f5e0a602","repo":"go-delve/delve","slug":"unsupported-constant-kind-v","errorCode":null,"errorMessage":"unsupported constant kind %v","messagePattern":"unsupported constant kind (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/proc/eval.go","lineNumber":851,"sourceCode":"\t\t\t}\n\t\t\treturn r, nil\n\t\t}\n\t}\n\tfor dwref, ctyp := range scope.BinInfo.consts {\n\t\tfor _, cval := range ctyp.values {\n\t\t\tif cval.fullName == name || strings.HasSuffix(cval.fullName, \"/\"+name) {\n\t\t\t\tt, err := scope.BinInfo.Images[dwref.imageIndex].Type(dwref.offset)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tv := newVariable(name, 0x0, t, scope.BinInfo, scope.Mem)\n\t\t\t\tswitch v.Kind {\n\t\t\t\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\t\t\t\tv.Value = constant.MakeInt64(cval.value)\n\t\t\t\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\t\t\t\tv.Value = constant.MakeUint64(uint64(cval.value))\n\t\t\t\tdefault:\n\t\t\t\t\treturn nil, fmt.Errorf(\"unsupported constant kind %v\", v.Kind)\n\t\t\t\t}\n\t\t\t\tv.Flags |= VariableConstant\n\t\t\t\tv.loaded = true\n\t\t\t\treturn v, nil\n\t\t\t}\n\t\t}\n\t}\n\treturn nil, nil\n}\n\n// image returns the image containing the current function.\nfunc (scope *EvalScope) image() *Image {\n\treturn scope.BinInfo.funcToImage(scope.Fn)\n}\n\n// evalStack stores the stack machine used to evaluate a program made of\n// evalop.Ops.\n// When an opcode sets callInjectionContinue execution of the program will be suspended","sourceCodeStart":833,"sourceCodeEnd":869,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/eval.go#L833-L869","documentation":"When a name resolves to a DWARF constant, findGlobalInternal builds a Variable and materializes its value. Only signed and unsigned integer kinds are supported; if the constant's reflect.Kind is anything else (float, string, bool constants recorded in DWARF with unsupported representation), the lookup aborts with this error instead of returning a wrong value.","triggerScenarios":"Evaluating an expression whose name matches an entry in BinInfo.consts whose DWARF-derived Variable kind is not one of the Int*/Uint* kinds handled in the switch — e.g. an untyped float, string, or bool constant whose kind materialized as something outside the supported set.","commonSituations":"Evaluating string or float constants that the DWARF producer recorded without an address (const with no memory location); version/toolchain changes altering how constants are emitted; suffix matching pulling in an unexpected constant kind.","solutions":["Use the constant's literal value directly in the expression instead of the symbol name (e.g. `x == \"mystring\"` rather than `x == MyStringConst`).","Check the constant's declared type; give it an explicit typed form (typed const of int kind) if you control the code.","Compare against a variable holding the constant's value in the debuggee.","If a legitimately integer constant hits this, verify DWARF is not corrupted; otherwise treat as unsupported and work around with literals."],"exampleFix":"// before\nscope.EvalExpression(\"MyConst\", cfg) // unsupported constant kind string\n// after\nscope.EvalExpression(\"\\\"myconst value\\\"\", cfg) // use the literal value","handlingStrategy":"fallback","validationCode":"// prefer inlining the constant's literal into the expression\nexpr := strings.ReplaceAll(expr, constName, constLiteralValue)","typeGuard":null,"tryCatchPattern":"v, err := scope.EvalExpression(name, cfg)\nif err != nil && strings.Contains(err.Error(), \"unsupported constant kind\") {\n    v, err = scope.EvalExpression(constLiteral, cfg) // substitute the literal value\n}","preventionTips":["Use literal values in expressions instead of symbolic constant names for non-integer constants","Declare constants with explicit integer types when you need to evaluate them by name","Compare against a variable initialized with the constant instead of the constant symbol","Pin Delve/Go versions; constant DWARF representation can change across toolchains"],"tags":["go","debugger","constants","symbol-resolution"],"backgroundTag":"unsupported-constant-kind","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}