{"record":{"id":"1a432f43cf236307","repo":"go-delve/delve","slug":"can-not-compare-s-variables","errorCode":null,"errorMessage":"can not compare %s variables","messagePattern":"can not compare (.+?) variables","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/eval.go","lineNumber":2676,"sourceCode":"\n\tswitch xv.Kind {\n\tcase reflect.Ptr:\n\t\teql = xv.Children[0].Addr == yv.Children[0].Addr\n\tcase reflect.Array:\n\t\tif int64(len(xv.Children)) != xv.Len || int64(len(yv.Children)) != yv.Len {\n\t\t\treturn false, errors.New(\"array too long for comparison\")\n\t\t}\n\t\teql, err = equalChildren(xv, yv, true)\n\tcase reflect.Struct:\n\t\tif len(xv.Children) != len(yv.Children) {\n\t\t\treturn false, nil\n\t\t}\n\t\tif int64(len(xv.Children)) != xv.Len || int64(len(yv.Children)) != yv.Len {\n\t\t\treturn false, errors.New(\"structure too deep for comparison\")\n\t\t}\n\t\teql, err = equalChildren(xv, yv, false)\n\tcase reflect.Slice, reflect.Map, reflect.Func, reflect.Chan:\n\t\treturn false, fmt.Errorf(\"can not compare %s variables\", xv.Kind.String())\n\tcase reflect.Interface:\n\t\tif xv.Children[0].RealType.String() != yv.Children[0].RealType.String() {\n\t\t\teql = false\n\t\t} else {\n\t\t\teql, err = compareOp(token.EQL, &xv.Children[0], &yv.Children[0])\n\t\t}\n\tdefault:\n\t\treturn false, fmt.Errorf(\"unimplemented comparison of %s variables\", xv.Kind.String())\n\t}\n\n\tif op == token.NEQ {\n\t\treturn !eql, err\n\t}\n\treturn eql, err\n}\n\nfunc (v *Variable) isNil() bool {\n\tswitch v.Kind {","sourceCodeStart":2658,"sourceCodeEnd":2694,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/eval.go#L2658-L2694","documentation":"For equality comparisons of composite kinds — slice, map, func and chan — Delve refuses to compare variables since Go itself only allows comparing those to nil. Because == on these kinds cannot be evaluated structurally, compareOp returns this error instead of guessing.","triggerScenarios":"Evaluating `p s1 == s2` where s1/s2 are slices, `p m1 == m2` for maps, `p f1 == f2` for funcs, or `p c1 == c2` for channels (all non-nil comparisons).","commonSituations":"Users expecting the debugger to deep-compare slices or maps the way a testing framework (reflect.DeepEqual) would; the debugger follows Go language rules instead.","solutions":["Compare element-wise: `p s1[0] == s2[0] && s1[1] == s2[1]`.","Compare lengths then elements: `p len(s1) == len(s2)` before element checks.","Compare maps by iterating keys, or compare a hash/serialized form if available."],"exampleFix":"// before\np s1 == s2\n// after\np len(s1) == len(s2) && s1[0] == s2[0]","handlingStrategy":"validation","validationCode":"// slices/maps/funcs/chans are only comparable to nil in Go\nswitch v.Kind {\ncase reflect.Slice, reflect.Map, reflect.Func, reflect.Chan:\n    // compare len and elements instead of v1 == v2\n}","typeGuard":"func nonComparableKind(k reflect.Kind) bool {\n    switch k {\n    case reflect.Slice, reflect.Map, reflect.Func, reflect.Chan:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Never use == between two slices/maps/funcs; only against nil.","Compare lengths first, then element-by-element.","Use reflect.DeepEqual semantics manually via element comparisons in Delve."],"tags":["debugger","expression-evaluation","comparison"],"backgroundTag":"non-comparable-types","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}