accounts/abi: array-parse error reports the wrong character (#35106)

This commit is contained in:
cui 2026-06-08 18:00:30 +08:00 committed by GitHub
parent 13d8df63f4
commit f1b2573dda
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -75,8 +75,11 @@ func parseElementaryType(unescapedSelector string) (string, string, error) {
parsedType = parsedType + string(rest[0])
rest = rest[1:]
}
if len(rest) == 0 || rest[0] != ']' {
return "", "", fmt.Errorf("failed to parse array: expected ']', got %c", unescapedSelector[0])
if len(rest) == 0 {
return "", "", fmt.Errorf("failed to parse array: expected ']', got end of string")
}
if rest[0] != ']' {
return "", "", fmt.Errorf("failed to parse array: expected ']', got %c", rest[0])
}
parsedType = parsedType + string(rest[0])
rest = rest[1:]