{"record":{"id":"bb7e8c8312a6cdcc","repo":"go-delve/delve","slug":"can-not-assign-big-integer-to-t-q","errorCode":null,"errorMessage":"can not assign big integer to %T.%q","messagePattern":"can not assign big integer to %T\\.%q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/terminal/starbind/conv.go","lineNumber":210,"sourceCode":"\t\t}\n\t\terr, _ = ierr.(error)\n\t\tif err == nil {\n\t\t\tpanic(ierr)\n\t\t}\n\t\terr = fmt.Errorf(\"can not assign to %T.%q: %v\", v.v.Interface(), name, err)\n\t}()\n\tif r, err := v.valueAttr(name); err != nil || r != nil {\n\t\treturn starlark.NoSuchAttrError(fmt.Sprintf(\"no field named %s in %T\", name, v.v.Interface()))\n\t}\n\tr := v.v.FieldByName(name)\n\tif !r.IsValid() {\n\t\treturn starlark.NoSuchAttrError(fmt.Sprintf(\"no field named %q in %T\", name, v.v.Interface()))\n\t}\n\tswitch value := value.(type) {\n\tcase starlark.Int:\n\t\tn, ok := value.Int64()\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"can not assign big integer to %T.%q\", v.v.Interface(), name)\n\t\t}\n\t\tr.SetInt(n)\n\tcase starlark.Float:\n\t\tr.SetFloat(float64(value))\n\tcase starlark.String:\n\t\tr.SetString(value.GoString())\n\tcase starlark.Bool:\n\t\tr.SetBool(bool(value))\n\tdefault:\n\t\treturn fmt.Errorf(\"can not assign value of type %T to %T.%q\", value, v.v.Interface(), name)\n\t}\n\treturn nil\n}\n\nfunc (v structAsStarlarkValue) valueAttr(name string) (starlark.Value, error) {\n\tif v.v.Type().Name() != \"Variable\" || (name != \"Value\" && name != \"Expr\") {\n\t\treturn nil, nil\n\t}","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/terminal/starbind/conv.go#L192-L228","documentation":"SetField in starbind rejects starlark.Int values whose magnitude does not fit in an int64: `n, ok := value.Int64()` fails for arbitrary-precision big ints, so the assignment to the Go int-typed field is refused with this message rather than silently truncating.","triggerScenarios":"A Starlark script assigns an integer literal or computed value exceeding int64 range (e.g. 2**64 or 10**30) to a Go struct field of int/int64 type, e.g. `var.Len = 2**70`.","commonSituations":"Bit-mask computations in scripts on 64-bit+ constants, or constructing huge counts/addresses that overflow int64.","solutions":["Reduce the value to something within signed 64-bit range (max 9223372036854775807)","If you need a large constant, store it as a string or split the computation","Check the target field's type; floats can hold large magnitudes if the field is float"],"exampleFix":"# before\nvar.Len = 2**70          # exceeds int64\n# after\nvar.Len = 1 << 62        # fits in int64","handlingStrategy":"validation","validationCode":"n = 2**70\nassert -2**63 <= n < 2**63, \"value exceeds int64 range\"\nvar.Len = n","typeGuard":"def fits_int64(x):\n    return -2**63 <= x < 2**63","tryCatchPattern":"try:\n    var.Len = big_value\nexcept Exception as e:\n    if \"big integer\" in str(e):\n        var.Len = clamp_to_int64(big_value)","preventionTips":["Clamp or mask computed constants to 64-bit range","Use floats only if the Go field is float","Avoid arbitrary-precision arithmetic feeding Go int fields"],"tags":["starlark","delve","scripting","integer-overflow"],"backgroundTag":"int64-overflow","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}