encoding/prototext: capture current reserved field behavior

This change was originally done in Google-internal cl/512993970.

Change-Id: I66ea95cd975b160892ed9f931312f1767cbc9fc9
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/608315
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
Reviewed-by: Christian Höppner <hoeppi@google.com>
diff --git a/encoding/prototext/decode_test.go b/encoding/prototext/decode_test.go
index be6e5a4..2346fe3 100644
--- a/encoding/prototext/decode_test.go
+++ b/encoding/prototext/decode_test.go
@@ -307,6 +307,16 @@
 		inputText:    "unknown_field: 456",
 		wantErr:      "unknown field",
 	}, {
+		desc:         "proto2 message contains reserved field name",
+		inputMessage: &pb2.ReservedFieldNames{},
+		inputText:    "reserved_field: 123 reserved_field { nested: 123 } opt_int32: 456",
+		wantMessage:  &pb2.ReservedFieldNames{OptInt32: proto.Int32(456)},
+	}, {
+		desc:         "proto3 message contains reserved field name",
+		inputMessage: &pb3.ReservedFieldNames{},
+		inputText:    "reserved_field: 123 reserved_field { nested: 123 } opt_int32: 456",
+		wantMessage:  &pb3.ReservedFieldNames{OptInt32: 456},
+	}, {
 		desc:         "proto2 message contains discarded unknown field",
 		umo:          prototext.UnmarshalOptions{DiscardUnknown: true},
 		inputMessage: &pb2.Scalars{},
diff --git a/internal/testprotos/textpb2/test.pb.go b/internal/testprotos/textpb2/test.pb.go
index 3199a6e..c9d5218 100644
--- a/internal/testprotos/textpb2/test.pb.go
+++ b/internal/testprotos/textpb2/test.pb.go
@@ -1375,6 +1375,52 @@
 	return nil
 }
 
+// Message contains reserved field name.
+type ReservedFieldNames struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	OptInt32 *int32 `protobuf:"varint,1,opt,name=opt_int32,json=optInt32" json:"opt_int32,omitempty"`
+}
+
+func (x *ReservedFieldNames) Reset() {
+	*x = ReservedFieldNames{}
+	mi := &file_internal_testprotos_textpb2_test_proto_msgTypes[17]
+	ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+	ms.StoreMessageInfo(mi)
+}
+
+func (x *ReservedFieldNames) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ReservedFieldNames) ProtoMessage() {}
+
+func (x *ReservedFieldNames) ProtoReflect() protoreflect.Message {
+	mi := &file_internal_testprotos_textpb2_test_proto_msgTypes[17]
+	if x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use ReservedFieldNames.ProtoReflect.Descriptor instead.
+func (*ReservedFieldNames) Descriptor() ([]byte, []int) {
+	return file_internal_testprotos_textpb2_test_proto_rawDescGZIP(), []int{17}
+}
+
+func (x *ReservedFieldNames) GetOptInt32() int32 {
+	if x != nil && x.OptInt32 != nil {
+		return *x.OptInt32
+	}
+	return 0
+}
+
 type Nests_OptGroup struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -1387,7 +1433,7 @@
 
 func (x *Nests_OptGroup) Reset() {
 	*x = Nests_OptGroup{}
-	mi := &file_internal_testprotos_textpb2_test_proto_msgTypes[19]
+	mi := &file_internal_testprotos_textpb2_test_proto_msgTypes[20]
 	ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
 	ms.StoreMessageInfo(mi)
 }
@@ -1399,7 +1445,7 @@
 func (*Nests_OptGroup) ProtoMessage() {}
 
 func (x *Nests_OptGroup) ProtoReflect() protoreflect.Message {
-	mi := &file_internal_testprotos_textpb2_test_proto_msgTypes[19]
+	mi := &file_internal_testprotos_textpb2_test_proto_msgTypes[20]
 	if x != nil {
 		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
 		if ms.LoadMessageInfo() == nil {
@@ -1446,7 +1492,7 @@
 
 func (x *Nests_RptGroup) Reset() {
 	*x = Nests_RptGroup{}
-	mi := &file_internal_testprotos_textpb2_test_proto_msgTypes[20]
+	mi := &file_internal_testprotos_textpb2_test_proto_msgTypes[21]
 	ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
 	ms.StoreMessageInfo(mi)
 }
@@ -1458,7 +1504,7 @@
 func (*Nests_RptGroup) ProtoMessage() {}
 
 func (x *Nests_RptGroup) ProtoReflect() protoreflect.Message {
-	mi := &file_internal_testprotos_textpb2_test_proto_msgTypes[20]
+	mi := &file_internal_testprotos_textpb2_test_proto_msgTypes[21]
 	if x != nil {
 		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
 		if ms.LoadMessageInfo() == nil {
@@ -1491,7 +1537,7 @@
 
 func (x *Nests_OptGroup_OptNestedGroup) Reset() {
 	*x = Nests_OptGroup_OptNestedGroup{}
-	mi := &file_internal_testprotos_textpb2_test_proto_msgTypes[21]
+	mi := &file_internal_testprotos_textpb2_test_proto_msgTypes[22]
 	ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
 	ms.StoreMessageInfo(mi)
 }
@@ -1503,7 +1549,7 @@
 func (*Nests_OptGroup_OptNestedGroup) ProtoMessage() {}
 
 func (x *Nests_OptGroup_OptNestedGroup) ProtoReflect() protoreflect.Message {
-	mi := &file_internal_testprotos_textpb2_test_proto_msgTypes[21]
+	mi := &file_internal_testprotos_textpb2_test_proto_msgTypes[22]
 	if x != nil {
 		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
 		if ms.LoadMessageInfo() == nil {
@@ -2069,50 +2115,54 @@
 	0x61, 0x73, 0x6b, 0x18, 0x28, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
 	0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c,
 	0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, 0x0c, 0x6f, 0x70, 0x74, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x6d,
-	0x61, 0x73, 0x6b, 0x2a, 0x21, 0x0a, 0x04, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x07, 0x0a, 0x03, 0x4f,
-	0x4e, 0x45, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x57, 0x4f, 0x10, 0x02, 0x12, 0x07, 0x0a,
-	0x03, 0x54, 0x45, 0x4e, 0x10, 0x0a, 0x3a, 0x31, 0x0a, 0x0c, 0x6f, 0x70, 0x74, 0x5f, 0x65, 0x78,
-	0x74, 0x5f, 0x62, 0x6f, 0x6f, 0x6c, 0x12, 0x0f, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x45, 0x78, 0x74,
-	0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x15, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x6f,
-	0x70, 0x74, 0x45, 0x78, 0x74, 0x42, 0x6f, 0x6f, 0x6c, 0x3a, 0x35, 0x0a, 0x0e, 0x6f, 0x70, 0x74,
-	0x5f, 0x65, 0x78, 0x74, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x0f, 0x2e, 0x70, 0x62,
-	0x32, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x16, 0x20, 0x01,
-	0x28, 0x09, 0x52, 0x0c, 0x6f, 0x70, 0x74, 0x45, 0x78, 0x74, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67,
-	0x3a, 0x3c, 0x0a, 0x0c, 0x6f, 0x70, 0x74, 0x5f, 0x65, 0x78, 0x74, 0x5f, 0x65, 0x6e, 0x75, 0x6d,
-	0x12, 0x0f, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e,
-	0x73, 0x18, 0x17, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x45, 0x6e,
-	0x75, 0x6d, 0x52, 0x0a, 0x6f, 0x70, 0x74, 0x45, 0x78, 0x74, 0x45, 0x6e, 0x75, 0x6d, 0x3a, 0x42,
-	0x0a, 0x0e, 0x6f, 0x70, 0x74, 0x5f, 0x65, 0x78, 0x74, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64,
-	0x12, 0x0f, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e,
-	0x73, 0x18, 0x18, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x4e, 0x65,
-	0x73, 0x74, 0x65, 0x64, 0x52, 0x0c, 0x6f, 0x70, 0x74, 0x45, 0x78, 0x74, 0x4e, 0x65, 0x73, 0x74,
-	0x65, 0x64, 0x3a, 0x4d, 0x0a, 0x0f, 0x6f, 0x70, 0x74, 0x5f, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61,
-	0x72, 0x74, 0x69, 0x61, 0x6c, 0x12, 0x0f, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x45, 0x78, 0x74, 0x65,
-	0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x19, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70,
-	0x62, 0x32, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72,
-	0x65, 0x64, 0x52, 0x0d, 0x6f, 0x70, 0x74, 0x45, 0x78, 0x74, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61,
-	0x6c, 0x3a, 0x37, 0x0a, 0x0f, 0x72, 0x70, 0x74, 0x5f, 0x65, 0x78, 0x74, 0x5f, 0x66, 0x69, 0x78,
-	0x65, 0x64, 0x33, 0x32, 0x12, 0x0f, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e,
-	0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x1f, 0x20, 0x03, 0x28, 0x07, 0x52, 0x0d, 0x72, 0x70, 0x74,
-	0x45, 0x78, 0x74, 0x46, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x3a, 0x3c, 0x0a, 0x0c, 0x72, 0x70,
-	0x74, 0x5f, 0x65, 0x78, 0x74, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x12, 0x0f, 0x2e, 0x70, 0x62, 0x32,
-	0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x20, 0x20, 0x03, 0x28,
-	0x0e, 0x32, 0x09, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x0a, 0x72, 0x70,
-	0x74, 0x45, 0x78, 0x74, 0x45, 0x6e, 0x75, 0x6d, 0x3a, 0x42, 0x0a, 0x0e, 0x72, 0x70, 0x74, 0x5f,
-	0x65, 0x78, 0x74, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x12, 0x0f, 0x2e, 0x70, 0x62, 0x32,
-	0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x21, 0x20, 0x03, 0x28,
-	0x0b, 0x32, 0x0b, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x0c,
-	0x72, 0x70, 0x74, 0x45, 0x78, 0x74, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x3a, 0x61, 0x0a, 0x15,
-	0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x65, 0x78, 0x74, 0x65,
-	0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0f, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x4d, 0x65, 0x73, 0x73,
-	0x61, 0x67, 0x65, 0x53, 0x65, 0x74, 0x18, 0x32, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x70,
-	0x62, 0x32, 0x2e, 0x46, 0x61, 0x6b, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x65,
-	0x74, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x6d, 0x65, 0x73, 0x73,
-	0x61, 0x67, 0x65, 0x53, 0x65, 0x74, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x42,
-	0x38, 0x5a, 0x36, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67,
-	0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x69, 0x6e,
-	0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f,
-	0x73, 0x2f, 0x74, 0x65, 0x78, 0x74, 0x70, 0x62, 0x32,
+	0x61, 0x73, 0x6b, 0x22, 0x41, 0x0a, 0x12, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x46,
+	0x69, 0x65, 0x6c, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x6f, 0x70, 0x74,
+	0x5f, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x6f, 0x70,
+	0x74, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x52, 0x0e, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64,
+	0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x2a, 0x21, 0x0a, 0x04, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x07,
+	0x0a, 0x03, 0x4f, 0x4e, 0x45, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x57, 0x4f, 0x10, 0x02,
+	0x12, 0x07, 0x0a, 0x03, 0x54, 0x45, 0x4e, 0x10, 0x0a, 0x3a, 0x31, 0x0a, 0x0c, 0x6f, 0x70, 0x74,
+	0x5f, 0x65, 0x78, 0x74, 0x5f, 0x62, 0x6f, 0x6f, 0x6c, 0x12, 0x0f, 0x2e, 0x70, 0x62, 0x32, 0x2e,
+	0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x15, 0x20, 0x01, 0x28, 0x08,
+	0x52, 0x0a, 0x6f, 0x70, 0x74, 0x45, 0x78, 0x74, 0x42, 0x6f, 0x6f, 0x6c, 0x3a, 0x35, 0x0a, 0x0e,
+	0x6f, 0x70, 0x74, 0x5f, 0x65, 0x78, 0x74, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x0f,
+	0x2e, 0x70, 0x62, 0x32, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18,
+	0x16, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x70, 0x74, 0x45, 0x78, 0x74, 0x53, 0x74, 0x72,
+	0x69, 0x6e, 0x67, 0x3a, 0x3c, 0x0a, 0x0c, 0x6f, 0x70, 0x74, 0x5f, 0x65, 0x78, 0x74, 0x5f, 0x65,
+	0x6e, 0x75, 0x6d, 0x12, 0x0f, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73,
+	0x69, 0x6f, 0x6e, 0x73, 0x18, 0x17, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x70, 0x62, 0x32,
+	0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x0a, 0x6f, 0x70, 0x74, 0x45, 0x78, 0x74, 0x45, 0x6e, 0x75,
+	0x6d, 0x3a, 0x42, 0x0a, 0x0e, 0x6f, 0x70, 0x74, 0x5f, 0x65, 0x78, 0x74, 0x5f, 0x6e, 0x65, 0x73,
+	0x74, 0x65, 0x64, 0x12, 0x0f, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73,
+	0x69, 0x6f, 0x6e, 0x73, 0x18, 0x18, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x70, 0x62, 0x32,
+	0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x0c, 0x6f, 0x70, 0x74, 0x45, 0x78, 0x74, 0x4e,
+	0x65, 0x73, 0x74, 0x65, 0x64, 0x3a, 0x4d, 0x0a, 0x0f, 0x6f, 0x70, 0x74, 0x5f, 0x65, 0x78, 0x74,
+	0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x12, 0x0f, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x45,
+	0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x19, 0x20, 0x01, 0x28, 0x0b, 0x32,
+	0x14, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x71,
+	0x75, 0x69, 0x72, 0x65, 0x64, 0x52, 0x0d, 0x6f, 0x70, 0x74, 0x45, 0x78, 0x74, 0x50, 0x61, 0x72,
+	0x74, 0x69, 0x61, 0x6c, 0x3a, 0x37, 0x0a, 0x0f, 0x72, 0x70, 0x74, 0x5f, 0x65, 0x78, 0x74, 0x5f,
+	0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x12, 0x0f, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x45, 0x78,
+	0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x1f, 0x20, 0x03, 0x28, 0x07, 0x52, 0x0d,
+	0x72, 0x70, 0x74, 0x45, 0x78, 0x74, 0x46, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x3a, 0x3c, 0x0a,
+	0x0c, 0x72, 0x70, 0x74, 0x5f, 0x65, 0x78, 0x74, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x12, 0x0f, 0x2e,
+	0x70, 0x62, 0x32, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x20,
+	0x20, 0x03, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x52,
+	0x0a, 0x72, 0x70, 0x74, 0x45, 0x78, 0x74, 0x45, 0x6e, 0x75, 0x6d, 0x3a, 0x42, 0x0a, 0x0e, 0x72,
+	0x70, 0x74, 0x5f, 0x65, 0x78, 0x74, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x12, 0x0f, 0x2e,
+	0x70, 0x62, 0x32, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x21,
+	0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65,
+	0x64, 0x52, 0x0c, 0x72, 0x70, 0x74, 0x45, 0x78, 0x74, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x3a,
+	0x61, 0x0a, 0x15, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x65,
+	0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0f, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x4d,
+	0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x65, 0x74, 0x18, 0x32, 0x20, 0x01, 0x28, 0x0b, 0x32,
+	0x1c, 0x2e, 0x70, 0x62, 0x32, 0x2e, 0x46, 0x61, 0x6b, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
+	0x65, 0x53, 0x65, 0x74, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x6d,
+	0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x65, 0x74, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69,
+	0x6f, 0x6e, 0x42, 0x38, 0x5a, 0x36, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c,
+	0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
+	0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72,
+	0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x74, 0x65, 0x78, 0x74, 0x70, 0x62, 0x32,
 }
 
 var (
@@ -2128,7 +2178,7 @@
 }
 
 var file_internal_testprotos_textpb2_test_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
-var file_internal_testprotos_textpb2_test_proto_msgTypes = make([]protoimpl.MessageInfo, 23)
+var file_internal_testprotos_textpb2_test_proto_msgTypes = make([]protoimpl.MessageInfo, 24)
 var file_internal_testprotos_textpb2_test_proto_goTypes = []any{
 	(Enum)(0),                             // 0: pb2.Enum
 	(Enums_NestedEnum)(0),                 // 1: pb2.Enums.NestedEnum
@@ -2149,70 +2199,71 @@
 	(*FakeMessageSet)(nil),                // 16: pb2.FakeMessageSet
 	(*FakeMessageSetExtension)(nil),       // 17: pb2.FakeMessageSetExtension
 	(*KnownTypes)(nil),                    // 18: pb2.KnownTypes
-	nil,                                   // 19: pb2.Maps.Int32ToStrEntry
-	nil,                                   // 20: pb2.Maps.StrToNestedEntry
-	(*Nests_OptGroup)(nil),                // 21: pb2.Nests.OptGroup
-	(*Nests_RptGroup)(nil),                // 22: pb2.Nests.RptGroup
-	(*Nests_OptGroup_OptNestedGroup)(nil), // 23: pb2.Nests.OptGroup.OptNestedGroup
-	nil,                                   // 24: pb2.IndirectRequired.StrToNestedEntry
-	(*wrapperspb.BoolValue)(nil),          // 25: google.protobuf.BoolValue
-	(*wrapperspb.Int32Value)(nil),         // 26: google.protobuf.Int32Value
-	(*wrapperspb.Int64Value)(nil),         // 27: google.protobuf.Int64Value
-	(*wrapperspb.UInt32Value)(nil),        // 28: google.protobuf.UInt32Value
-	(*wrapperspb.UInt64Value)(nil),        // 29: google.protobuf.UInt64Value
-	(*wrapperspb.FloatValue)(nil),         // 30: google.protobuf.FloatValue
-	(*wrapperspb.DoubleValue)(nil),        // 31: google.protobuf.DoubleValue
-	(*wrapperspb.StringValue)(nil),        // 32: google.protobuf.StringValue
-	(*wrapperspb.BytesValue)(nil),         // 33: google.protobuf.BytesValue
-	(*durationpb.Duration)(nil),           // 34: google.protobuf.Duration
-	(*timestamppb.Timestamp)(nil),         // 35: google.protobuf.Timestamp
-	(*structpb.Struct)(nil),               // 36: google.protobuf.Struct
-	(*structpb.ListValue)(nil),            // 37: google.protobuf.ListValue
-	(*structpb.Value)(nil),                // 38: google.protobuf.Value
-	(structpb.NullValue)(0),               // 39: google.protobuf.NullValue
-	(*emptypb.Empty)(nil),                 // 40: google.protobuf.Empty
-	(*anypb.Any)(nil),                     // 41: google.protobuf.Any
-	(*fieldmaskpb.FieldMask)(nil),         // 42: google.protobuf.FieldMask
+	(*ReservedFieldNames)(nil),            // 19: pb2.ReservedFieldNames
+	nil,                                   // 20: pb2.Maps.Int32ToStrEntry
+	nil,                                   // 21: pb2.Maps.StrToNestedEntry
+	(*Nests_OptGroup)(nil),                // 22: pb2.Nests.OptGroup
+	(*Nests_RptGroup)(nil),                // 23: pb2.Nests.RptGroup
+	(*Nests_OptGroup_OptNestedGroup)(nil), // 24: pb2.Nests.OptGroup.OptNestedGroup
+	nil,                                   // 25: pb2.IndirectRequired.StrToNestedEntry
+	(*wrapperspb.BoolValue)(nil),          // 26: google.protobuf.BoolValue
+	(*wrapperspb.Int32Value)(nil),         // 27: google.protobuf.Int32Value
+	(*wrapperspb.Int64Value)(nil),         // 28: google.protobuf.Int64Value
+	(*wrapperspb.UInt32Value)(nil),        // 29: google.protobuf.UInt32Value
+	(*wrapperspb.UInt64Value)(nil),        // 30: google.protobuf.UInt64Value
+	(*wrapperspb.FloatValue)(nil),         // 31: google.protobuf.FloatValue
+	(*wrapperspb.DoubleValue)(nil),        // 32: google.protobuf.DoubleValue
+	(*wrapperspb.StringValue)(nil),        // 33: google.protobuf.StringValue
+	(*wrapperspb.BytesValue)(nil),         // 34: google.protobuf.BytesValue
+	(*durationpb.Duration)(nil),           // 35: google.protobuf.Duration
+	(*timestamppb.Timestamp)(nil),         // 36: google.protobuf.Timestamp
+	(*structpb.Struct)(nil),               // 37: google.protobuf.Struct
+	(*structpb.ListValue)(nil),            // 38: google.protobuf.ListValue
+	(*structpb.Value)(nil),                // 39: google.protobuf.Value
+	(structpb.NullValue)(0),               // 40: google.protobuf.NullValue
+	(*emptypb.Empty)(nil),                 // 41: google.protobuf.Empty
+	(*anypb.Any)(nil),                     // 42: google.protobuf.Any
+	(*fieldmaskpb.FieldMask)(nil),         // 43: google.protobuf.FieldMask
 }
 var file_internal_testprotos_textpb2_test_proto_depIdxs = []int32{
 	0,  // 0: pb2.Enums.opt_enum:type_name -> pb2.Enum
 	0,  // 1: pb2.Enums.rpt_enum:type_name -> pb2.Enum
 	1,  // 2: pb2.Enums.opt_nested_enum:type_name -> pb2.Enums.NestedEnum
 	1,  // 3: pb2.Enums.rpt_nested_enum:type_name -> pb2.Enums.NestedEnum
-	19, // 4: pb2.Maps.int32_to_str:type_name -> pb2.Maps.Int32ToStrEntry
-	20, // 5: pb2.Maps.str_to_nested:type_name -> pb2.Maps.StrToNestedEntry
+	20, // 4: pb2.Maps.int32_to_str:type_name -> pb2.Maps.Int32ToStrEntry
+	21, // 5: pb2.Maps.str_to_nested:type_name -> pb2.Maps.StrToNestedEntry
 	6,  // 6: pb2.Nested.opt_nested:type_name -> pb2.Nested
 	6,  // 7: pb2.Nests.opt_nested:type_name -> pb2.Nested
-	21, // 8: pb2.Nests.optgroup:type_name -> pb2.Nests.OptGroup
+	22, // 8: pb2.Nests.optgroup:type_name -> pb2.Nests.OptGroup
 	6,  // 9: pb2.Nests.rpt_nested:type_name -> pb2.Nested
-	22, // 10: pb2.Nests.rptgroup:type_name -> pb2.Nests.RptGroup
+	23, // 10: pb2.Nests.rptgroup:type_name -> pb2.Nests.RptGroup
 	0,  // 11: pb2.Requireds.req_enum:type_name -> pb2.Enum
 	6,  // 12: pb2.Requireds.req_nested:type_name -> pb2.Nested
 	10, // 13: pb2.IndirectRequired.opt_nested:type_name -> pb2.NestedWithRequired
 	10, // 14: pb2.IndirectRequired.rpt_nested:type_name -> pb2.NestedWithRequired
-	24, // 15: pb2.IndirectRequired.str_to_nested:type_name -> pb2.IndirectRequired.StrToNestedEntry
+	25, // 15: pb2.IndirectRequired.str_to_nested:type_name -> pb2.IndirectRequired.StrToNestedEntry
 	10, // 16: pb2.IndirectRequired.oneof_nested:type_name -> pb2.NestedWithRequired
-	25, // 17: pb2.KnownTypes.opt_bool:type_name -> google.protobuf.BoolValue
-	26, // 18: pb2.KnownTypes.opt_int32:type_name -> google.protobuf.Int32Value
-	27, // 19: pb2.KnownTypes.opt_int64:type_name -> google.protobuf.Int64Value
-	28, // 20: pb2.KnownTypes.opt_uint32:type_name -> google.protobuf.UInt32Value
-	29, // 21: pb2.KnownTypes.opt_uint64:type_name -> google.protobuf.UInt64Value
-	30, // 22: pb2.KnownTypes.opt_float:type_name -> google.protobuf.FloatValue
-	31, // 23: pb2.KnownTypes.opt_double:type_name -> google.protobuf.DoubleValue
-	32, // 24: pb2.KnownTypes.opt_string:type_name -> google.protobuf.StringValue
-	33, // 25: pb2.KnownTypes.opt_bytes:type_name -> google.protobuf.BytesValue
-	34, // 26: pb2.KnownTypes.opt_duration:type_name -> google.protobuf.Duration
-	35, // 27: pb2.KnownTypes.opt_timestamp:type_name -> google.protobuf.Timestamp
-	36, // 28: pb2.KnownTypes.opt_struct:type_name -> google.protobuf.Struct
-	37, // 29: pb2.KnownTypes.opt_list:type_name -> google.protobuf.ListValue
-	38, // 30: pb2.KnownTypes.opt_value:type_name -> google.protobuf.Value
-	39, // 31: pb2.KnownTypes.opt_null:type_name -> google.protobuf.NullValue
-	40, // 32: pb2.KnownTypes.opt_empty:type_name -> google.protobuf.Empty
-	41, // 33: pb2.KnownTypes.opt_any:type_name -> google.protobuf.Any
-	42, // 34: pb2.KnownTypes.opt_fieldmask:type_name -> google.protobuf.FieldMask
+	26, // 17: pb2.KnownTypes.opt_bool:type_name -> google.protobuf.BoolValue
+	27, // 18: pb2.KnownTypes.opt_int32:type_name -> google.protobuf.Int32Value
+	28, // 19: pb2.KnownTypes.opt_int64:type_name -> google.protobuf.Int64Value
+	29, // 20: pb2.KnownTypes.opt_uint32:type_name -> google.protobuf.UInt32Value
+	30, // 21: pb2.KnownTypes.opt_uint64:type_name -> google.protobuf.UInt64Value
+	31, // 22: pb2.KnownTypes.opt_float:type_name -> google.protobuf.FloatValue
+	32, // 23: pb2.KnownTypes.opt_double:type_name -> google.protobuf.DoubleValue
+	33, // 24: pb2.KnownTypes.opt_string:type_name -> google.protobuf.StringValue
+	34, // 25: pb2.KnownTypes.opt_bytes:type_name -> google.protobuf.BytesValue
+	35, // 26: pb2.KnownTypes.opt_duration:type_name -> google.protobuf.Duration
+	36, // 27: pb2.KnownTypes.opt_timestamp:type_name -> google.protobuf.Timestamp
+	37, // 28: pb2.KnownTypes.opt_struct:type_name -> google.protobuf.Struct
+	38, // 29: pb2.KnownTypes.opt_list:type_name -> google.protobuf.ListValue
+	39, // 30: pb2.KnownTypes.opt_value:type_name -> google.protobuf.Value
+	40, // 31: pb2.KnownTypes.opt_null:type_name -> google.protobuf.NullValue
+	41, // 32: pb2.KnownTypes.opt_empty:type_name -> google.protobuf.Empty
+	42, // 33: pb2.KnownTypes.opt_any:type_name -> google.protobuf.Any
+	43, // 34: pb2.KnownTypes.opt_fieldmask:type_name -> google.protobuf.FieldMask
 	6,  // 35: pb2.Maps.StrToNestedEntry.value:type_name -> pb2.Nested
 	6,  // 36: pb2.Nests.OptGroup.opt_nested:type_name -> pb2.Nested
-	23, // 37: pb2.Nests.OptGroup.optnestedgroup:type_name -> pb2.Nests.OptGroup.OptNestedGroup
+	24, // 37: pb2.Nests.OptGroup.optnestedgroup:type_name -> pb2.Nests.OptGroup.OptNestedGroup
 	10, // 38: pb2.IndirectRequired.StrToNestedEntry.value:type_name -> pb2.NestedWithRequired
 	12, // 39: pb2.opt_ext_bool:extendee -> pb2.Extensions
 	12, // 40: pb2.opt_ext_string:extendee -> pb2.Extensions
@@ -2271,7 +2322,7 @@
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_internal_testprotos_textpb2_test_proto_rawDesc,
 			NumEnums:      2,
-			NumMessages:   23,
+			NumMessages:   24,
 			NumExtensions: 21,
 			NumServices:   0,
 		},
diff --git a/internal/testprotos/textpb2/test.proto b/internal/testprotos/textpb2/test.proto
index 571a741..48a14fd 100644
--- a/internal/testprotos/textpb2/test.proto
+++ b/internal/testprotos/textpb2/test.proto
@@ -234,3 +234,9 @@
 
   optional google.protobuf.FieldMask opt_fieldmask = 40;
 }
+
+// Message contains reserved field name.
+message ReservedFieldNames {
+  reserved "reserved_field";
+  optional int32 opt_int32 = 1;
+}
diff --git a/internal/testprotos/textpb3/test.pb.go b/internal/testprotos/textpb3/test.pb.go
index a9c4d12..5b7d9ef 100644
--- a/internal/testprotos/textpb3/test.pb.go
+++ b/internal/testprotos/textpb3/test.pb.go
@@ -885,6 +885,52 @@
 	return ""
 }
 
+// Message contains reserved field name.
+type ReservedFieldNames struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	OptInt32 int32 `protobuf:"varint,1,opt,name=opt_int32,json=optInt32,proto3" json:"opt_int32,omitempty"`
+}
+
+func (x *ReservedFieldNames) Reset() {
+	*x = ReservedFieldNames{}
+	mi := &file_internal_testprotos_textpb3_test_proto_msgTypes[9]
+	ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+	ms.StoreMessageInfo(mi)
+}
+
+func (x *ReservedFieldNames) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ReservedFieldNames) ProtoMessage() {}
+
+func (x *ReservedFieldNames) ProtoReflect() protoreflect.Message {
+	mi := &file_internal_testprotos_textpb3_test_proto_msgTypes[9]
+	if x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use ReservedFieldNames.ProtoReflect.Descriptor instead.
+func (*ReservedFieldNames) Descriptor() ([]byte, []int) {
+	return file_internal_testprotos_textpb3_test_proto_rawDescGZIP(), []int{9}
+}
+
+func (x *ReservedFieldNames) GetOptInt32() int32 {
+	if x != nil {
+		return x.OptInt32
+	}
+	return 0
+}
+
 var File_internal_testprotos_textpb3_test_proto protoreflect.FileDescriptor
 
 var file_internal_testprotos_textpb3_test_proto_rawDesc = []byte{
@@ -1043,14 +1089,18 @@
 	0x6f, 0x66, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x26,
 	0x0a, 0x09, 0x4a, 0x53, 0x4f, 0x4e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x73,
 	0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66,
-	0x6f, 0x6f, 0x5f, 0x62, 0x61, 0x72, 0x2a, 0x2b, 0x0a, 0x04, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x08,
-	0x0a, 0x04, 0x5a, 0x45, 0x52, 0x4f, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x4e, 0x45, 0x10,
-	0x01, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x57, 0x4f, 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x45,
-	0x4e, 0x10, 0x0a, 0x42, 0x38, 0x5a, 0x36, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f,
-	0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
-	0x66, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x70,
-	0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x74, 0x65, 0x78, 0x74, 0x70, 0x62, 0x33, 0x62, 0x06, 0x70,
-	0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x6f, 0x6f, 0x5f, 0x62, 0x61, 0x72, 0x22, 0x41, 0x0a, 0x12, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76,
+	0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x1b, 0x0a, 0x09,
+	0x6f, 0x70, 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
+	0x08, 0x6f, 0x70, 0x74, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x52, 0x0e, 0x72, 0x65, 0x73, 0x65, 0x72,
+	0x76, 0x65, 0x64, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x2a, 0x2b, 0x0a, 0x04, 0x45, 0x6e, 0x75,
+	0x6d, 0x12, 0x08, 0x0a, 0x04, 0x5a, 0x45, 0x52, 0x4f, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x4f,
+	0x4e, 0x45, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x57, 0x4f, 0x10, 0x02, 0x12, 0x07, 0x0a,
+	0x03, 0x54, 0x45, 0x4e, 0x10, 0x0a, 0x42, 0x38, 0x5a, 0x36, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
+	0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74,
+	0x6f, 0x62, 0x75, 0x66, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65,
+	0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x74, 0x65, 0x78, 0x74, 0x70, 0x62, 0x33,
+	0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -1066,24 +1116,25 @@
 }
 
 var file_internal_testprotos_textpb3_test_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
-var file_internal_testprotos_textpb3_test_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
+var file_internal_testprotos_textpb3_test_proto_msgTypes = make([]protoimpl.MessageInfo, 15)
 var file_internal_testprotos_textpb3_test_proto_goTypes = []any{
-	(Enum)(0),              // 0: pb3.Enum
-	(Enums_NestedEnum)(0),  // 1: pb3.Enums.NestedEnum
-	(*Scalars)(nil),        // 2: pb3.Scalars
-	(*Repeats)(nil),        // 3: pb3.Repeats
-	(*Proto3Optional)(nil), // 4: pb3.Proto3Optional
-	(*Enums)(nil),          // 5: pb3.Enums
-	(*Nests)(nil),          // 6: pb3.Nests
-	(*Nested)(nil),         // 7: pb3.Nested
-	(*Oneofs)(nil),         // 8: pb3.Oneofs
-	(*Maps)(nil),           // 9: pb3.Maps
-	(*JSONNames)(nil),      // 10: pb3.JSONNames
-	nil,                    // 11: pb3.Maps.Int32ToStrEntry
-	nil,                    // 12: pb3.Maps.BoolToUint32Entry
-	nil,                    // 13: pb3.Maps.Uint64ToEnumEntry
-	nil,                    // 14: pb3.Maps.StrToNestedEntry
-	nil,                    // 15: pb3.Maps.StrToOneofsEntry
+	(Enum)(0),                  // 0: pb3.Enum
+	(Enums_NestedEnum)(0),      // 1: pb3.Enums.NestedEnum
+	(*Scalars)(nil),            // 2: pb3.Scalars
+	(*Repeats)(nil),            // 3: pb3.Repeats
+	(*Proto3Optional)(nil),     // 4: pb3.Proto3Optional
+	(*Enums)(nil),              // 5: pb3.Enums
+	(*Nests)(nil),              // 6: pb3.Nests
+	(*Nested)(nil),             // 7: pb3.Nested
+	(*Oneofs)(nil),             // 8: pb3.Oneofs
+	(*Maps)(nil),               // 9: pb3.Maps
+	(*JSONNames)(nil),          // 10: pb3.JSONNames
+	(*ReservedFieldNames)(nil), // 11: pb3.ReservedFieldNames
+	nil,                        // 12: pb3.Maps.Int32ToStrEntry
+	nil,                        // 13: pb3.Maps.BoolToUint32Entry
+	nil,                        // 14: pb3.Maps.Uint64ToEnumEntry
+	nil,                        // 15: pb3.Maps.StrToNestedEntry
+	nil,                        // 16: pb3.Maps.StrToOneofsEntry
 }
 var file_internal_testprotos_textpb3_test_proto_depIdxs = []int32{
 	0,  // 0: pb3.Proto3Optional.opt_enum:type_name -> pb3.Enum
@@ -1094,11 +1145,11 @@
 	7,  // 5: pb3.Nested.s_nested:type_name -> pb3.Nested
 	0,  // 6: pb3.Oneofs.oneof_enum:type_name -> pb3.Enum
 	7,  // 7: pb3.Oneofs.oneof_nested:type_name -> pb3.Nested
-	11, // 8: pb3.Maps.int32_to_str:type_name -> pb3.Maps.Int32ToStrEntry
-	12, // 9: pb3.Maps.bool_to_uint32:type_name -> pb3.Maps.BoolToUint32Entry
-	13, // 10: pb3.Maps.uint64_to_enum:type_name -> pb3.Maps.Uint64ToEnumEntry
-	14, // 11: pb3.Maps.str_to_nested:type_name -> pb3.Maps.StrToNestedEntry
-	15, // 12: pb3.Maps.str_to_oneofs:type_name -> pb3.Maps.StrToOneofsEntry
+	12, // 8: pb3.Maps.int32_to_str:type_name -> pb3.Maps.Int32ToStrEntry
+	13, // 9: pb3.Maps.bool_to_uint32:type_name -> pb3.Maps.BoolToUint32Entry
+	14, // 10: pb3.Maps.uint64_to_enum:type_name -> pb3.Maps.Uint64ToEnumEntry
+	15, // 11: pb3.Maps.str_to_nested:type_name -> pb3.Maps.StrToNestedEntry
+	16, // 12: pb3.Maps.str_to_oneofs:type_name -> pb3.Maps.StrToOneofsEntry
 	0,  // 13: pb3.Maps.Uint64ToEnumEntry.value:type_name -> pb3.Enum
 	7,  // 14: pb3.Maps.StrToNestedEntry.value:type_name -> pb3.Nested
 	8,  // 15: pb3.Maps.StrToOneofsEntry.value:type_name -> pb3.Oneofs
@@ -1126,7 +1177,7 @@
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_internal_testprotos_textpb3_test_proto_rawDesc,
 			NumEnums:      2,
-			NumMessages:   14,
+			NumMessages:   15,
 			NumExtensions: 0,
 			NumServices:   0,
 		},
diff --git a/internal/testprotos/textpb3/test.proto b/internal/testprotos/textpb3/test.proto
index 577932a..7b3f406 100644
--- a/internal/testprotos/textpb3/test.proto
+++ b/internal/testprotos/textpb3/test.proto
@@ -114,3 +114,9 @@
 message JSONNames {
   string s_string = 1 [json_name = "foo_bar"];
 }
+
+// Message contains reserved field name.
+message ReservedFieldNames {
+  reserved "reserved_field";
+  int32 opt_int32 = 1;
+}