aboutsummaryrefslogtreecommitdiff
path: root/scripts/qapi/expr.py
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2021-09-08 06:54:28 +0200
committerMarkus Armbruster <armbru@redhat.com>2021-09-08 15:30:30 +0200
commit62f27589f8549d6cf1f7fe21ed55ce6f2f705450 (patch)
tree497a5b605de158706d4371152f55f3b695ceda2e /scripts/qapi/expr.py
parent71f03ef9f66b020d58acad5227e886102db41127 (diff)
downloadqemu-62f27589f8549d6cf1f7fe21ed55ce6f2f705450.zip
qemu-62f27589f8549d6cf1f7fe21ed55ce6f2f705450.tar.gz
qemu-62f27589f8549d6cf1f7fe21ed55ce6f2f705450.tar.bz2
qapi: Fix bogus error for 'if': { 'not': '' }
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210908045428.2689093-6-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> [check_infix()'s type hint fixed]
Diffstat (limited to 'scripts/qapi/expr.py')
-rw-r--r--scripts/qapi/expr.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py
index b62f0a3..90bde50 100644
--- a/scripts/qapi/expr.py
+++ b/scripts/qapi/expr.py
@@ -293,17 +293,22 @@ def check_if(expr: _JSONObject, info: QAPISourceInfo, source: str) -> None:
info,
"'if' condition of %s has conflicting keys" % source)
- oper, operands = next(iter(cond.items()))
+ if 'not' in cond:
+ _check_if(cond['not'])
+ elif 'all' in cond:
+ _check_infix('all', cond['all'])
+ else:
+ _check_infix('any', cond['any'])
+
+ def _check_infix(operator: str, operands: object) -> None:
+ if not isinstance(operands, list):
+ raise QAPISemError(
+ info,
+ "'%s' condition of %s must be an array"
+ % (operator, source))
if not operands:
raise QAPISemError(
info, "'if' condition [] of %s is useless" % source)
-
- if oper == "not":
- _check_if(operands)
- return
- if oper in ("all", "any") and not isinstance(operands, list):
- raise QAPISemError(
- info, "'%s' condition of %s must be an array" % (oper, source))
for operand in operands:
_check_if(operand)