mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 14:45:48 +00:00
qapi: Forbid 'any' inside an alternate
The whole point of an alternate is to allow some type-safety while still accepting more than one JSON type. Meanwhile, the 'any' type exists to bypass type-safety altogether. The two are incompatible: you can't accept every type, and still tell which branch of the alternate to use for the parse; fix this to give a sane error instead of a Python stack trace. Note that other types that can't be alternate members are caught earlier, by check_type(). Backports commit 46534309e667fd860720f983c2c9aefe0354340d from qemu
This commit is contained in:
parent
907771516e
commit
74da8f0eea
|
@ -632,7 +632,10 @@ def check_alternate(expr, expr_info):
|
|||
value,
|
||||
allow_metas=['built-in', 'union', 'struct', 'enum'])
|
||||
qtype = find_alternate_member_qtype(value)
|
||||
assert qtype
|
||||
if not qtype:
|
||||
raise QAPIExprError(expr_info,
|
||||
"Alternate '%s' member '%s' cannot use "
|
||||
"type '%s'" % (name, key, value))
|
||||
if qtype in types_seen:
|
||||
raise QAPIExprError(expr_info,
|
||||
"Alternate '%s' member '%s' can't "
|
||||
|
|
Loading…
Reference in a new issue