Skip to content

Commit 34f7b25

Browse files
author
Markus Armbruster
committed
qapi: Tweak error messages for unknown / conflicting 'if' keys
Signed-off-by: Markus Armbruster <[email protected]> Message-Id: <[email protected]> Reviewed-by: Marc-André Lureau <[email protected]>
1 parent 6dcf037 commit 34f7b25

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

scripts/qapi/expr.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,12 @@ def _check_if(cond: Union[str, object]) -> None:
286286
raise QAPISemError(
287287
info,
288288
"'if' condition of %s must be a string or an object" % source)
289+
check_keys(cond, info, "'if' condition of %s" % source, [],
290+
["all", "any", "not"])
289291
if len(cond) != 1:
290292
raise QAPISemError(
291293
info,
292-
"'if' condition dict of %s must have one key: "
293-
"'all', 'any' or 'not'" % source)
294-
check_keys(cond, info, "'if' condition", [],
295-
["all", "any", "not"])
294+
"'if' condition of %s has conflicting keys" % source)
296295

297296
oper, operands = next(iter(cond.items()))
298297
if not operands:

tests/qapi-schema/bad-if-key.err

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
bad-if-key.json: In struct 'TestIfStruct':
2-
bad-if-key.json:2: 'if' condition has unknown key 'value'
2+
bad-if-key.json:2: 'if' condition of struct has unknown key 'value'
33
Valid keys are 'all', 'any', 'not'.

tests/qapi-schema/bad-if-keys.err

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
bad-if-keys.json: In struct 'TestIfStruct':
2-
bad-if-keys.json:2: 'if' condition dict of struct must have one key: 'all', 'any' or 'not'
2+
bad-if-keys.json:2: 'if' condition of struct has conflicting keys
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
enum-if-invalid.json: In enum 'TestIfEnum':
2-
enum-if-invalid.json:2: 'if' condition has unknown key 'val'
2+
enum-if-invalid.json:2: 'if' condition of 'data' member 'bar' has unknown key 'val'
33
Valid keys are 'all', 'any', 'not'.

0 commit comments

Comments
 (0)