Message ID | 20190924132830.15835-25-armbru@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | qapi: Pay back some frontend technical debt | expand |
On 9/24/19 8:28 AM, Markus Armbruster wrote: > Point to the previous definition, unless it's a built-in. > > Signed-off-by: Markus Armbruster <armbru@redhat.com> > --- > if other_ent: > + if other_ent.info: > + where = QAPIError(other_ent.info, None, "previous definition") > + raise QAPISemError( > + ent.info, > + "'%s' is already defined\n%s" % (ent.name, where)) > raise QAPISemError( > ent.info, "%s is already defined" % other_ent.describe()) Nice. Reviewed-by: Eric Blake <eblake@redhat.com>
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 29b75345bb..c38e7cf27d 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -1748,6 +1748,11 @@ class QAPISchema(object): # because they're liable to clash in generated C. other_ent = self._entity_dict.get(ent.name) if other_ent: + if other_ent.info: + where = QAPIError(other_ent.info, None, "previous definition") + raise QAPISemError( + ent.info, + "'%s' is already defined\n%s" % (ent.name, where)) raise QAPISemError( ent.info, "%s is already defined" % other_ent.describe()) self._entity_dict[ent.name] = ent diff --git a/tests/qapi-schema/redefined-command.err b/tests/qapi-schema/redefined-command.err index b77a05d354..54e366bbf3 100644 --- a/tests/qapi-schema/redefined-command.err +++ b/tests/qapi-schema/redefined-command.err @@ -1,2 +1,4 @@ tests/qapi-schema/redefined-command.json: In command 'foo': -tests/qapi-schema/redefined-command.json:3: command 'foo' is already defined +tests/qapi-schema/redefined-command.json:3: 'foo' is already defined +tests/qapi-schema/redefined-command.json: In command 'foo': +tests/qapi-schema/redefined-command.json:2: previous definition diff --git a/tests/qapi-schema/redefined-event.err b/tests/qapi-schema/redefined-event.err index fd02d38157..606c6e4497 100644 --- a/tests/qapi-schema/redefined-event.err +++ b/tests/qapi-schema/redefined-event.err @@ -1,2 +1,4 @@ tests/qapi-schema/redefined-event.json: In event 'EVENT_A': -tests/qapi-schema/redefined-event.json:3: event 'EVENT_A' is already defined +tests/qapi-schema/redefined-event.json:3: 'EVENT_A' is already defined +tests/qapi-schema/redefined-event.json: In event 'EVENT_A': +tests/qapi-schema/redefined-event.json:2: previous definition diff --git a/tests/qapi-schema/redefined-type.err b/tests/qapi-schema/redefined-type.err index 39f51c14ea..77786f98ae 100644 --- a/tests/qapi-schema/redefined-type.err +++ b/tests/qapi-schema/redefined-type.err @@ -1,2 +1,4 @@ tests/qapi-schema/redefined-type.json: In enum 'foo': -tests/qapi-schema/redefined-type.json:3: struct type 'foo' is already defined +tests/qapi-schema/redefined-type.json:3: 'foo' is already defined +tests/qapi-schema/redefined-type.json: In struct 'foo': +tests/qapi-schema/redefined-type.json:2: previous definition
Point to the previous definition, unless it's a built-in. Signed-off-by: Markus Armbruster <armbru@redhat.com> --- scripts/qapi/common.py | 5 +++++ tests/qapi-schema/redefined-command.err | 4 +++- tests/qapi-schema/redefined-event.err | 4 +++- tests/qapi-schema/redefined-type.err | 4 +++- 4 files changed, 14 insertions(+), 3 deletions(-)