On Thu, Sep 29, 2011 at 5:51 AM, Armin Rigo <ar...@tunes.org> wrote: > Hi Maciek, > > On Thu, Sep 29, 2011 at 10:33, Carl Friedrich Bolz <cfb...@gmx.de> wrote: >>> +class Entry(ExtRegistryEntry): >>> + _about_ = is_constant >>> + >>> + def compute_result_annotation(self, s_arg): >>> + from pypy.annotation import model >>> + r = model.SomeBool() >>> + r.const = s_arg.is_constant() >>> + return r > > This is wrong. We tried at some point to have is_constant() but > failed. The issue is that when calling is_constant(x), even if 'x' > turns out not to be constant in the end, it's possible that its > initial annotation says that it is a constant. In this case, crash, > because you return "SomeBool(const=True)" and later > "SomeBool(const=False)", which is not a superset of the previous > value. > > Try with a test like this: > > def f(n): > is_constant(n) > def g(n): > f(5) > f(n) > > > A bientôt, > > Armin. > _______________________________________________ > pypy-dev mailing list > pypy-dev@python.org > http://mail.python.org/mailman/listinfo/pypy-dev >
It works (maybe should be documented so) because you have a specialization on the constantness of function arg. _______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev