On 11/18/2015 01:53 AM, Eric Blake wrote: > In general, designing user interfaces that rely on case > distinction is poor practice. Another benefit of enforcing > a restriction against case-insensitive clashes is that we > no longer have to worry about the situation of enum values > that could be distinguished by case if mapped by c_name(), > but which cannot be distinguished when mapped to C as > ALL_CAPS by c_enum_const() [via c_name(name, False).upper()]. > Thus, having the generator look for case collisions up front > will prevent developers from worrying whether different > munging rules for member names compared to enum values as a > discriminator will cause any problems in qapi unions. >
> @@ -1202,11 +1205,32 @@ class QAPISchema(object): > def _def_entity(self, ent): > # Only the predefined types are allowed to not have info > assert ent.info or self._predefining > - assert ent.name not in self._entity_dict > - self._entity_dict[ent.name] = ent > + # On insertion, we need to check for an exact match in either > + # namespace, then for case collision in a single namespace > + if self.lookup_entity(ent.name): > + raise QAPIExprError(ent.info, > + "Entity '%s' already defined" % end.name) Latent typo (s/end/ent/); we can't hit this line of code until we nuke ad hoc parser checks. So using an assert here is better in the meantime. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature