{"record":{"id":"489059a684f1db17","repo":"go-delve/delve","slug":"operations-on-non-finite-floats-not-implemented","errorCode":null,"errorMessage":"operations on non-finite floats not implemented","messagePattern":"operations on non-finite floats not implemented","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"pkg/proc/eval.go","lineNumber":25,"sourceCode":"\t\"go/ast\"\n\t\"go/constant\"\n\t\"go/parser\"\n\t\"go/token\"\n\t\"reflect\"\n\t\"runtime/debug\"\n\t\"sort\"\n\t\"strings\"\n\n\t\"github.com/go-delve/delve/pkg/astutil\"\n\t\"github.com/go-delve/delve/pkg/dwarf/godwarf\"\n\t\"github.com/go-delve/delve/pkg/dwarf/op\"\n\t\"github.com/go-delve/delve/pkg/dwarf/reader\"\n\t\"github.com/go-delve/delve/pkg/goversion\"\n\t\"github.com/go-delve/delve/pkg/logflags\"\n\t\"github.com/go-delve/delve/pkg/proc/evalop\"\n)\n\nvar errOperationOnSpecialFloat = errors.New(\"operations on non-finite floats not implemented\")\n\nconst (\n\tgoDictionaryName = \".dict\"\n\tgoClosurePtr     = \".closureptr\"\n)\n\n// EvalScope is the scope for variable evaluation. Contains the thread,\n// current location (PC), and canonical frame address.\ntype EvalScope struct {\n\tLocation\n\tRegs     op.DwarfRegisters\n\tMem      MemoryReadWriter // Target's memory\n\tg        *G\n\tthreadID int\n\tBinInfo  *BinaryInfo\n\ttarget   *Target\n\tloadCfg  *LoadConfig\n","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/eval.go#L7-L43","documentation":"errOperationOnSpecialFloat (pkg/proc/eval.go:25) is a package-level sentinel meaning an expression evaluation attempted arithmetic/comparison on a non-finite float (+Inf, -Inf, NaN). Delve's evaluator does not implement IEEE-754 semantics for special floats, so instead of computing a wrong result it refuses with this error.","triggerScenarios":"Evaluating expressions (print/display/watch, evalop pipeline) where an operand is +Inf/-Inf/NaN — e.g. print x*2 where x = Inf, or comparisons involving a NaN-valued variable returned by the inferior.","commonSituations":"Debugging numeric code that legitimately produced Inf/NaN (division by zero, overflow, math.Sqrt(-1)) and then writing expressions over those values; printing aggregates that include NaN fields.","solutions":["Print the raw variable (print x) instead of evaluating arithmetic over Inf/NaN values.","Restructure the expression to avoid special floats, e.g. inspect components separately or cast to compare bits.","Read bit patterns for exact diagnosis: print math.Float64bits(x) to see the NaN/Inf encoding.","Fix the upstream computation in the program if Inf/NaN were unexpected; the debugger is telling you the value is special."],"exampleFix":"// before\n(dlv) print total / count   // count == 0 -> total is +Inf -> error\n\n// after\n(dlv) print total\n(dlv) print math.Float64bits(total)  // inspect bits instead of arithmetic","handlingStrategy":"try-catch","validationCode":"v, err := dbg EvalVariable(name)\nif err == nil && v.Kind == reflect.Float64 {\n    // check for Inf/NaN before building arithmetic expressions over it\n}","typeGuard":"func isSpecialFloat(f float64) bool { return math.IsInf(f, 0) || math.IsNaN(f) }","tryCatchPattern":"val, err := dbg.EvalExpression(expr)\nif err != nil && strings.Contains(err.Error(), \"non-finite floats\") {\n    // fall back to printing raw components / bits\n    val, err = dbg.EvalExpression(\"math.Float64bits(\" + expr + \")\")\n}","preventionTips":["Print raw values before writing arithmetic expressions over them.","Expect Inf/NaN when debugging division, overflow, or math functions.","Use math.Float64bits/Float32bits to inspect special values bit-exactly.","Sanitize or branch on special floats in watch expressions."],"tags":["expression-evaluation","floating-point","go","delve"],"backgroundTag":"non-finite-float-operation","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}