diff --git a/scripts/qapi.py b/scripts/qapi.py index 8aa2775f12..3693b520da 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -825,11 +825,11 @@ def check_alternate(expr, info): else: conflicting.add('QTYPE_QNUM') conflicting.add('QTYPE_QBOOL') - if conflicting & set(types_seen): - raise QAPISemError(info, "Alternate '%s' member '%s' can't " - "be distinguished from member '%s'" - % (name, key, types_seen[qtype])) for qt in conflicting: + if qt in types_seen: + raise QAPISemError(info, "Alternate '%s' member '%s' can't " + "be distinguished from member '%s'" + % (name, key, types_seen[qt])) types_seen[qt] = key diff --git a/tests/Makefile.include b/tests/Makefile.include index f08b7418f0..00af45ca85 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -376,6 +376,8 @@ qapi-schema += alternate-conflict-dict.json qapi-schema += alternate-conflict-enum-bool.json qapi-schema += alternate-conflict-enum-int.json qapi-schema += alternate-conflict-string.json +qapi-schema += alternate-conflict-bool-string.json +qapi-schema += alternate-conflict-num-string.json qapi-schema += alternate-empty.json qapi-schema += alternate-nested.json qapi-schema += alternate-unknown.json diff --git a/tests/qapi-schema/alternate-conflict-bool-string.err b/tests/qapi-schema/alternate-conflict-bool-string.err new file mode 100644 index 0000000000..e52fee7620 --- /dev/null +++ b/tests/qapi-schema/alternate-conflict-bool-string.err @@ -0,0 +1 @@ +tests/qapi-schema/alternate-conflict-bool-string.json:2: Alternate 'Alt' member 'two' can't be distinguished from member 'one' diff --git a/tests/qapi-schema/alternate-conflict-bool-string.exit b/tests/qapi-schema/alternate-conflict-bool-string.exit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/alternate-conflict-bool-string.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/alternate-conflict-bool-string.json b/tests/qapi-schema/alternate-conflict-bool-string.json new file mode 100644 index 0000000000..0544de10f3 --- /dev/null +++ b/tests/qapi-schema/alternate-conflict-bool-string.json @@ -0,0 +1,4 @@ +# alternate branches of 'str' type conflict with all scalar types +{ 'alternate': 'Alt', + 'data': { 'one': 'bool', + 'two': 'str' } } diff --git a/tests/qapi-schema/alternate-conflict-bool-string.out b/tests/qapi-schema/alternate-conflict-bool-string.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/alternate-conflict-num-string.err b/tests/qapi-schema/alternate-conflict-num-string.err new file mode 100644 index 0000000000..5ba3827dd1 --- /dev/null +++ b/tests/qapi-schema/alternate-conflict-num-string.err @@ -0,0 +1 @@ +tests/qapi-schema/alternate-conflict-num-string.json:2: Alternate 'Alt' member 'two' can't be distinguished from member 'one' diff --git a/tests/qapi-schema/alternate-conflict-num-string.exit b/tests/qapi-schema/alternate-conflict-num-string.exit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/alternate-conflict-num-string.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/alternate-conflict-num-string.json b/tests/qapi-schema/alternate-conflict-num-string.json new file mode 100644 index 0000000000..ae901449af --- /dev/null +++ b/tests/qapi-schema/alternate-conflict-num-string.json @@ -0,0 +1,4 @@ +# alternate branches of 'str' type conflict with all scalar types +{ 'alternate': 'Alt', + 'data': { 'one': 'number', + 'two': 'str' } } diff --git a/tests/qapi-schema/alternate-conflict-num-string.out b/tests/qapi-schema/alternate-conflict-num-string.out new file mode 100644 index 0000000000..e69de29bb2