Now that commit e4ba22b3 has separated the C representation of qapi unions so that tag values no longer collide with non-variant members, we must adjust QAPISchemaObjectTypeVariant.check() to match. The fix is conceptually simple - track a separate dictionary of tag names we have seen so far, different from the dictionary of non-variant names. And while the non-variant seen array gets reset for each new variant (because the JSON object does not have collisions between separate branches), the map of tag names is not reset.
Signed-off-by: Eric Blake <ebl...@redhat.com> --- v9: new patch, split off from v8 7/17 --- scripts/qapi.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 3cf051f..10bf16f 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -1055,10 +1055,11 @@ class QAPISchemaObjectTypeVariants(object): else: # simple union or alternate assert self.tag_member in seen.itervalues() assert isinstance(self.tag_member.type, QAPISchemaEnumType) + cases = {} for v in self.variants: # Reset seen array for each variant, since QMP names from one # branch do not affect another branch - v.check(schema, self.tag_member.type, dict(seen), union) + v.check(schema, self.tag_member.type, dict(seen), cases, union) class QAPISchemaObjectTypeVariant(QAPISchemaObjectTypeMember): @@ -1066,8 +1067,8 @@ class QAPISchemaObjectTypeVariant(QAPISchemaObjectTypeMember): QAPISchemaObjectTypeMember.__init__(self, name, typ, False) # TODO drop 'union' param once tag_type is sufficient to spot alternates - def check(self, schema, tag_type, seen, union): - QAPISchemaObjectTypeMember.check(self, schema, dict(seen)) + def check(self, schema, tag_type, seen, cases, union): + QAPISchemaObjectTypeMember.check(self, schema, cases) assert self.name in tag_type.values if union: # If this variant is used within a union, then each member -- 2.4.3