mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-04-17 02:42:35 +00:00
protobuf: remove the check for reserved field numbers.
Field numbers in the reserved range are semantically valid, although the protocol buffer compiler may reject attempts to define fields in this range. Change-Id: Ib939ed5f4fef09b29047b509829b2f01494bfb6a Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/461238 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Michael Stapelberg <stapelberg@google.com>
This commit is contained in:
parent
a8d446d548
commit
31a5920811
@ -29,12 +29,8 @@ const (
|
||||
)
|
||||
|
||||
// IsValid reports whether the field number is semantically valid.
|
||||
//
|
||||
// Note that while numbers within the reserved range are semantically invalid,
|
||||
// they are syntactically valid in the wire format.
|
||||
// Implementations may treat records with reserved field numbers as unknown.
|
||||
func (n Number) IsValid() bool {
|
||||
return MinValidNumber <= n && n < FirstReservedNumber || LastReservedNumber < n && n <= MaxValidNumber
|
||||
return MinValidNumber <= n && n <= MaxValidNumber
|
||||
}
|
||||
|
||||
// Type represents the wire type.
|
||||
|
Loading…
x
Reference in New Issue
Block a user