Explorar o código

handle sanity check for repeating enums correctly

@rubynerd %!s(int64=8) %!d(string=hai) anos
pai
achega
f3e86fd26a
Modificáronse 1 ficheiros con 11 adicións e 3 borrados
  1. 11 3
      ruby/ext/google/protobuf_c/storage.c

+ 11 - 3
ruby/ext/google/protobuf_c/storage.c

@@ -595,12 +595,20 @@ static void check_repeated_field_type(VALUE val, const upb_fielddef* field) {
     rb_raise(rb_eTypeError, "Repeated field array has wrong element type");
   }
 
-  if (self->field_type == UPB_TYPE_MESSAGE ||
-      self->field_type == UPB_TYPE_ENUM) {
+  if (self->field_type == UPB_TYPE_MESSAGE) { 
     if (self->field_type_class !=
         Descriptor_msgclass(get_def_obj(upb_fielddef_subdef(field)))) {
       rb_raise(rb_eTypeError,
-               "Repeated field array has wrong message/enum class");
+               "Repeated field array has wrong message class");
+    }
+  }
+
+
+  if (self->field_type == UPB_TYPE_ENUM) {
+    if (self->field_type_class !=
+        EnumDescriptor_enummodule(get_def_obj(upb_fielddef_subdef(field)))) {
+      rb_raise(rb_eTypeError,
+               "Repeated field array has wrong enum class");
     }
   }
 }