go-delve/delve · info

operations on non-finite floats not implemented

Error message

operations on non-finite floats not implemented

What it means

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.

Source

Thrown at pkg/proc/eval.go:25

	"go/ast"
	"go/constant"
	"go/parser"
	"go/token"
	"reflect"
	"runtime/debug"
	"sort"
	"strings"

	"github.com/go-delve/delve/pkg/astutil"
	"github.com/go-delve/delve/pkg/dwarf/godwarf"
	"github.com/go-delve/delve/pkg/dwarf/op"
	"github.com/go-delve/delve/pkg/dwarf/reader"
	"github.com/go-delve/delve/pkg/goversion"
	"github.com/go-delve/delve/pkg/logflags"
	"github.com/go-delve/delve/pkg/proc/evalop"
)

var errOperationOnSpecialFloat = errors.New("operations on non-finite floats not implemented")

const (
	goDictionaryName = ".dict"
	goClosurePtr     = ".closureptr"
)

// EvalScope is the scope for variable evaluation. Contains the thread,
// current location (PC), and canonical frame address.
type EvalScope struct {
	Location
	Regs     op.DwarfRegisters
	Mem      MemoryReadWriter // Target's memory
	g        *G
	threadID int
	BinInfo  *BinaryInfo
	target   *Target
	loadCfg  *LoadConfig

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Print the raw variable (print x) instead of evaluating arithmetic over Inf/NaN values.
  2. Restructure the expression to avoid special floats, e.g. inspect components separately or cast to compare bits.
  3. Read bit patterns for exact diagnosis: print math.Float64bits(x) to see the NaN/Inf encoding.
  4. Fix the upstream computation in the program if Inf/NaN were unexpected; the debugger is telling you the value is special.

Example fix

// before
(dlv) print total / count   // count == 0 -> total is +Inf -> error

// after
(dlv) print total
(dlv) print math.Float64bits(total)  // inspect bits instead of arithmetic
Defensive patterns

Strategy: try-catch

Validate before calling

v, err := dbg EvalVariable(name)
if err == nil && v.Kind == reflect.Float64 {
    // check for Inf/NaN before building arithmetic expressions over it
}

Type guard

func isSpecialFloat(f float64) bool { return math.IsInf(f, 0) || math.IsNaN(f) }

Try / catch

val, err := dbg.EvalExpression(expr)
if err != nil && strings.Contains(err.Error(), "non-finite floats") {
    // fall back to printing raw components / bits
    val, err = dbg.EvalExpression("math.Float64bits(" + expr + ")")
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31). Data as JSON: /api/errors/489059a684f1db17. Report an issue: GitHub.