On Wed, Nov 22, 2023 at 7:59 AM Markus Armbruster <arm...@redhat.com> wrote:
>
> John Snow <js...@redhat.com> writes:
>
> > There's more conditionals in here than we can reasonably pack into a
> > terse little statement, so break it apart into something more explicit.
> >
> > (When would a built-in array ever cause a QAPISemError? I don't know,
> > maybe never - but the type system wasn't happy all the same.)
> >
> > Signed-off-by: John Snow <js...@redhat.com>
> > ---
> >  scripts/qapi/schema.py | 11 +++++++++--
> >  1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
> > index 462acb2bb61..164d86c4064 100644
> > --- a/scripts/qapi/schema.py
> > +++ b/scripts/qapi/schema.py
> > @@ -384,9 +384,16 @@ def need_has_if_optional(self):
> >
> >      def check(self, schema):
> >          super().check(schema)
> > +
> > +        if self.info:
> > +            assert self.info.defn_meta  # guaranteed to be set by expr.py
> > +            what = self.info.defn_meta
> > +        else:
> > +            what = 'built-in array'
> > +
> >          self._element_type = schema.resolve_type(
> > -            self._element_type_name, self.info,
> > -            self.info and self.info.defn_meta)
> > +            self._element_type_name, self.info, what
> > +        )
> >          assert not isinstance(self.element_type, QAPISchemaArrayType)
> >
> >      def set_module(self, schema):
>
> What problem are you solving here?
>

1. "self.info and self.info.defn_meta" is the wrong type ifn't self.info
2. self.info.defn_meta is *also* not guaranteed by static types

ultimately: we need to assert self.info and self.info.defn_meta both;
but it's possible (?) that we don't have self.info in the case that
we're a built-in array, so I handle that.


Reply via email to