{"record":{"id":"4e5260b2d82e94eb","repo":"go-delve/delve","slug":"variable-to-reslice-is-not-an-array-slice-or-map","errorCode":null,"errorMessage":"variable to reslice is not an array, slice, or map","messagePattern":"variable to reslice is not an array, slice, or map","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/eval.go","lineNumber":2946,"sourceCode":"// up to cfg.MaxArrayValues children.\nfunc (v *Variable) LoadResliced(start int, cfg LoadConfig) (newV *Variable, err error) {\n\tswitch v.Kind {\n\tcase reflect.Array, reflect.Slice:\n\t\tlow, high := int64(start), int64(start+cfg.MaxArrayValues)\n\t\tif high > v.Len {\n\t\t\thigh = v.Len\n\t\t}\n\t\tnewV, err = v.reslice(low, high, false)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tcase reflect.Map:\n\t\tnewV = v.clone()\n\t\tnewV.Children = nil\n\t\tnewV.loaded = false\n\t\tnewV.mapSkip = start\n\tdefault:\n\t\treturn nil, errors.New(\"variable to reslice is not an array, slice, or map\")\n\t}\n\tnewV.loadValue(cfg)\n\treturn newV, nil\n}\n\nfunc (v *Variable) reslice(low int64, high int64, trustLen bool) (*Variable, error) {\n\twrong := false\n\tcptrNeedsFakeSlice := false\n\tif v.Flags&VariableCPtr == 0 {\n\t\tif v.Kind == reflect.Slice {\n\t\t\twrong = low < 0 || low > v.Cap || high < 0 || high > v.Cap\n\t\t} else {\n\t\t\twrong = low < 0 || low > v.Len || high < 0 || high > v.Len\n\t\t}\n\t} else {\n\t\twrong = low < 0 || high < 0\n\t\tif high == 0 {\n\t\t\thigh = low","sourceCodeStart":2928,"sourceCodeEnd":2964,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/eval.go#L2928-L2964","documentation":"LoadResliced re-reads a container starting at a given index (used for paging through large arrays/slices/maps in the UI). It only supports array, slice, and map kinds; any other kind reaching the switch's default branch throws this error. Strings, structs, pointers, and interfaces cannot be resliced this way.","triggerScenarios":"Calling LoadResliced (directly or via UI/RPC paging of a large variable) on a Variable whose Kind is not Array, Slice, or Map — e.g. a string, a nil/unknown kind, a struct, or a pointer.","commonSituations":"A frontend or custom client paging a variable tree and calling reslice-style APIs on the wrong node type; code assuming a variable is a slice when it is actually a string or pointer; reflection-driven tooling misclassifying kinds.","solutions":["Check v.Kind before calling LoadResliced and only call it for reflect.Array, reflect.Slice, or reflect.Map","For strings use string indexing/slicing (reslice) semantics instead of LoadResliced","Dereference pointers first (load the pointee) before attempting container paging","If the kind is unexpected, reload the variable with a proper LoadConfig so Kind is populated correctly"],"exampleFix":"// before\nnewV, err := v.LoadResliced(start, cfg) // v.Kind == reflect.String -> error\n\n// after\nswitch v.Kind {\ncase reflect.Array, reflect.Slice, reflect.Map:\n    newV, err = v.LoadResliced(start, cfg)\ndefault:\n    err = fmt.Errorf(\"cannot reslice kind %s\", v.Kind)\n}","handlingStrategy":"type-guard","validationCode":"// before calling LoadResliced\nif v.Kind != reflect.Array && v.Kind != reflect.Slice && v.Kind != reflect.Map {\n    return fmt.Errorf(\"cannot reslice kind %s\", v.Kind)\n}\nnewV, err := v.LoadResliced(start, cfg)","typeGuard":"func resliceable(v *proc.Variable) bool {\n    return v != nil && (v.Kind == reflect.Array || v.Kind == reflect.Slice || v.Kind == reflect.Map)\n}","tryCatchPattern":"// caller pattern\nnewV, err := v.LoadResliced(start, cfg)\nif err != nil && strings.Contains(err.Error(), \"not an array, slice, or map\") {\n    // fall back to loading the variable whole or re-reading its pointee\n    v.LoadValue(cfg)\n}","preventionTips":["Check Variable.Kind before any reslice/paging call","Dereference pointers and unwrap interfaces before paging their contents","Treat strings with string reslice semantics, not LoadResliced","Ensure variables are loaded with a proper LoadConfig so Kind is accurate"],"tags":["go","debugger","reslice","type-mismatch"],"backgroundTag":"unsupported-kind-for-reslice","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}