A conflict must be marked even when the two dictionaries being compared differ on whether the key is marked optional.
Signed-off-by: Eric Blake <ebl...@redhat.com> --- scripts/qapi.py | 4 +++- tests/qapi-schema/flat-union-branch-clash.json | 2 +- tests/qapi-schema/struct-base-clash-deep.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 4ec8646..ad20d3e 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -419,7 +419,9 @@ def check_member_clash(expr_info, base_name, data, source = ""): assert base base_members = base['data'] for key in data.keys(): - if key in base_members: + if key.startswith('*'): + key = key[1:] + if key in base_members or "*%s" %key in base_members: raise QAPIExprError(expr_info, "Member name '%s'%s clashes with base '%s'" %(key, source, base_name)) diff --git a/tests/qapi-schema/flat-union-branch-clash.json b/tests/qapi-schema/flat-union-branch-clash.json index b3c6ffe..8fb054f 100644 --- a/tests/qapi-schema/flat-union-branch-clash.json +++ b/tests/qapi-schema/flat-union-branch-clash.json @@ -2,7 +2,7 @@ { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } { 'struct': 'Base', - 'data': { 'enum1': 'TestEnum', 'name': 'str' } } + 'data': { 'enum1': 'TestEnum', '*name': 'str' } } { 'struct': 'Branch1', 'data': { 'name': 'str' } } { 'struct': 'Branch2', diff --git a/tests/qapi-schema/struct-base-clash-deep.json b/tests/qapi-schema/struct-base-clash-deep.json index 08c8c9c..552fe94 100644 --- a/tests/qapi-schema/struct-base-clash-deep.json +++ b/tests/qapi-schema/struct-base-clash-deep.json @@ -6,4 +6,4 @@ 'data': { 'value': 'int' } } { 'struct': 'Sub', 'base': 'Mid', - 'data': { 'name': 'str' } } + 'data': { '*name': 'str' } } -- 2.1.0