golang/go · error
invalid register number: {name}
Error message
invalid register number: {name} What it means
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.
Source
Thrown at src/cmd/asm/internal/arch/arm64.go:228
return int64(reg&31)<<16 | int64(op)<<22 | int64(uint16(count)), nil
}
// ARM64RegisterArrangement constructs an ARM64 vector register arrangement.
func ARM64RegisterArrangement(reg int16, name, arng string) (int64, error) {
var curQ, curSize, prefix uint16
if name[0] != 'V' && name[0] != 'Z' && name[0] != 'P' {
return 0, errors.New("expect V0-V31, Z0-Z31, or P0-P15; found: " + name)
}
switch name[0] {
case 'V':
prefix = 0
case 'Z':
prefix = 1
case 'P':
prefix = 2
}
if reg < 0 {
return 0, errors.New("invalid register number: " + name)
}
switch arng {
case "B8":
curSize = 0
curQ = 0
case "B16":
curSize = 0
curQ = 1
case "H4":
curSize = 1
curQ = 0
case "H8":
curSize = 1
curQ = 1
case "S2":
curSize = 2
curQ = 0
case "S4":View on GitHub (pinned to b6b368adc5)
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.
Example fix
; before — out-of-range vector register LD1 Z32.S, (R0) ; after — use a valid register index LD1 Z0.S, (R0)
Defensive patterns
Strategy: validation
Validate before calling
// Validate the register index is in range before emitting assembly.
func validVectorIndex(prefix byte, n int) bool {
switch prefix {
case 'V', 'Z': return n >= 0 && n <= 31
case 'P': return n >= 0 && n <= 15
}
return false
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- invalid register for shift operation
- expect V0-V31, Z0-Z31, or P0-P15; found: {name}
- invalid arrangement in ARM64 register list
- Loong64 extension: invalid LSX/LASX register: {reg}
- globalThis.crypto is not available, polyfill required (crypt
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/06207c74b7cacc37.
Report an issue: GitHub.