A repeated scalar can arrive packed in one Len field or spread across many tagged fields, and a correct decoder accepts both and yields the same list. Today you make a repeated field decode identically either way.
Decode a repeated scalar field to the same list whether it is packed or unpacked.
A decoder must be liberal about repeated scalars because the two wire forms are both legal and both common. The packed form is a single Len field whose payload is the values’ varints concatenated. The unpacked form is the same values each written as its own tagged field, so the number repeats. Proto3 packs by default, but an older sender, or a message merged from several sources, may send the unpacked form - and the specification requires a decoder to accept either for the same field.
The rule: for a field the descriptor marks repeated, gather contributions across
every occurrence. A Len occurrence unpacks into many values; a Varint occurrence
contributes one. Pin both encodings of [3, 270, 86942] on field 4 - the packed
0x22 0x06 ... and the unpacked triple of 0x20-tagged varints - and confirm they
decode to the identical list. This tolerance is the wire-format side of protobuf’s
forward compatibility, the same instinct as skipping unknowns and filling defaults.
// for a repeated scalar field, accept either wire form:// Len -> UnpackVarints(f.Bytes) contributes many values// Varint-> f.Varint contributes one value// concatenate contributions across every occurrence of the number