{"record":{"id":"06207c74b7cacc37","repo":"golang/go","slug":"invalid-register-number-name","errorCode":null,"errorMessage":"invalid register number: {name}","messagePattern":"invalid register number: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/asm/internal/arch/arm64.go","lineNumber":228,"sourceCode":"\treturn int64(reg&31)<<16 | int64(op)<<22 | int64(uint16(count)), nil\n}\n\n// ARM64RegisterArrangement constructs an ARM64 vector register arrangement.\nfunc ARM64RegisterArrangement(reg int16, name, arng string) (int64, error) {\n\tvar curQ, curSize, prefix uint16\n\tif name[0] != 'V' && name[0] != 'Z' && name[0] != 'P' {\n\t\treturn 0, errors.New(\"expect V0-V31, Z0-Z31, or P0-P15; found: \" + name)\n\t}\n\tswitch name[0] {\n\tcase 'V':\n\t\tprefix = 0\n\tcase 'Z':\n\t\tprefix = 1\n\tcase 'P':\n\t\tprefix = 2\n\t}\n\tif reg < 0 {\n\t\treturn 0, errors.New(\"invalid register number: \" + name)\n\t}\n\tswitch arng {\n\tcase \"B8\":\n\t\tcurSize = 0\n\t\tcurQ = 0\n\tcase \"B16\":\n\t\tcurSize = 0\n\t\tcurQ = 1\n\tcase \"H4\":\n\t\tcurSize = 1\n\t\tcurQ = 0\n\tcase \"H8\":\n\t\tcurSize = 1\n\t\tcurQ = 1\n\tcase \"S2\":\n\t\tcurSize = 2\n\t\tcurQ = 0\n\tcase \"S4\":","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/asm/internal/arch/arm64.go#L210-L246","documentation":"The Go assembler's ARM64RegisterArrangement returns this error when the numeric register encoding passed in is negative (arm64.go:227-229). After confirming the name prefix is V/Z/P, the function checks the numeric reg value; a negative reg indicates the register name failed to parse to a valid index (the caller represents parse failure as a sentinel negative). The error message echoes the offending name so the developer can locate it.","triggerScenarios":"Triggered when ARM64RegisterArrangement is called with reg < 0 after the name-prefix check passed (arm64.go:227). This happens when the register-number parsing upstream returned a negative sentinel for a name like 'V99' (out of range) or a malformed token that still began with V/Z/P but had no valid trailing number.","commonSituations":"Writing V32+ or Z32+ (the valid range is 0-31) in an assembly file. A register token like 'V' with no number, or 'V0x1' with invalid trailing characters. Assembler-fed input where the number parse failed silently and produced the negative sentinel.","solutions":["Use register numbers within range: V0-V31, Z0-Z31, P0-P15.","Correct typos in the register token — ensure it is V/Z/P followed by a clean decimal number.","If generating assembly programmatically, validate the register index is in [0, 31] (or [0, 15] for P) before emitting.","Check the assembler error line in the .s file pointed to by the message and fix the offending operand."],"exampleFix":"; before — out-of-range vector register\nLD1 Z32.S, (R0)\n\n; after — use a valid register index\nLD1 Z0.S, (R0)","handlingStrategy":"validation","validationCode":"// Validate the register index is in range before emitting assembly.\nfunc validVectorIndex(prefix byte, n int) bool {\n    switch prefix {\n    case 'V', 'Z': return n >= 0 && n <= 31\n    case 'P': return n >= 0 && n <= 15\n    }\n    return false\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use register indices within range: V/Z 0-31, P 0-15.","Ensure register tokens are prefix + clean decimal number.","Validate programmatically-generated assembly before writing .s files."],"tags":["go","asm","arm64","register","assembler"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}