Skip to content

Commit

Permalink
protobuf: remove the check for reserved field numbers.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
sbenzaquen authored and stapelberg committed Jan 12, 2023
1 parent a8d446d commit 31a5920
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions encoding/protowire/wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 31a5920

Please sign in to comment.