
Hello, Hopefully a very simple question. I am trying out RPython toolchain. pypy 2.6, python 2.7. I am using the translator shell. Here's my simple example: python bin/translatorshell.py class mtype(): def __init__(self): self.x = 0; def mmm(x): z = x.x + 1 return z t = Translation(mmm, [mtype]) t.annotate() and it gives me the following. if you put mtype class and mmm function definitions in a separate module, then you can see it complains about this line: z = x.x + 1. Why can't it infer type for all arguments and the result here? I know i am missing something basic. Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/nfs/site/disks/scl.work.58/ppt/aayupov/hld/pypy-2.6.0-src/rpython/translator/interactive.py", line 89, in annotate return self.driver.annotate() File "/nfs/site/disks/scl.work.58/ppt/aayupov/hld/pypy-2.6.0-src/rpython/translator/driver.py", line 106, in proc return self.proceed(backend_goal) File "/nfs/site/disks/scl.work.58/ppt/aayupov/hld/pypy-2.6.0-src/rpython/translator/driver.py", line 549, in proceed return self._execute(goals, task_skip = self._maybe_skip()) File "/nfs/site/disks/scl.work.58/ppt/aayupov/hld/pypy-2.6.0-src/rpython/translator/tool/taskengine.py", line 114, in _execute res = self._do(goal, taskcallable, *args, **kwds) File "/nfs/site/disks/scl.work.58/ppt/aayupov/hld/pypy-2.6.0-src/rpython/translator/driver.py", line 277, in _do res = func() File "/nfs/site/disks/scl.work.58/ppt/aayupov/hld/pypy-2.6.0-src/rpython/translator/driver.py", line 314, in task_annotate s = annotator.build_types(self.entry_point, self.inputtypes) File "/nfs/site/disks/scl.work.58/ppt/aayupov/hld/pypy-2.6.0-src/rpython/annotator/annrpython.py", line 89, in build_types return self.build_graph_types(flowgraph, inputcells, complete_now=complete_now) File "/nfs/site/disks/scl.work.58/ppt/aayupov/hld/pypy-2.6.0-src/rpython/annotator/annrpython.py", line 135, in build_graph_types self.complete() File "/nfs/site/disks/scl.work.58/ppt/aayupov/hld/pypy-2.6.0-src/rpython/annotator/annrpython.py", line 211, in complete raise annmodel.AnnotatorError(text) rpython.annotator.model.AnnotatorError: Blocked block -- operation cannot succeed v0 = getattr(x_0, ('x')) In <FunctionGraph of (__main__:1)mmm at 0x7ffff2b69ed0>: no source! Known variable annotations: x_0 = SomeInstance(can_be_None=False, classdef=__main__.mtype) Thanks! Andrey

On 28 August 2015 at 04:23, Andrey Ayupov <andrey.ayupov@gmail.com> wrote:
It never saw the creation of an mytpe, so it doesn't know that mtypes have an x attribute, let alone know what type it has. Try a bigger entry point: def entry(x, y): m = mtype() return mmm(m) -- William Leslie Notice: Likely much of this email is, by the nature of copyright, covered under copyright law. You absolutely MAY reproduce any part of it in accordance with the copyright law of the nation you are reading this in. Any attempt to DENY YOU THOSE RIGHTS would be illegal without prior contractual agreement.

On 28 August 2015 at 13:34, William ML Leslie <william.leslie.ttg@gmail.com> wrote:
er I meant: def entry(): m = mtype() return mmm(m) t = Translation(entry, []) -- William Leslie Notice: Likely much of this email is, by the nature of copyright, covered under copyright law. You absolutely MAY reproduce any part of it in accordance with the copyright law of the nation you are reading this in. Any attempt to DENY YOU THOSE RIGHTS would be illegal without prior contractual agreement.

On 28 August 2015 at 04:23, Andrey Ayupov <andrey.ayupov@gmail.com> wrote:
It never saw the creation of an mytpe, so it doesn't know that mtypes have an x attribute, let alone know what type it has. Try a bigger entry point: def entry(x, y): m = mtype() return mmm(m) -- William Leslie Notice: Likely much of this email is, by the nature of copyright, covered under copyright law. You absolutely MAY reproduce any part of it in accordance with the copyright law of the nation you are reading this in. Any attempt to DENY YOU THOSE RIGHTS would be illegal without prior contractual agreement.

On 28 August 2015 at 13:34, William ML Leslie <william.leslie.ttg@gmail.com> wrote:
er I meant: def entry(): m = mtype() return mmm(m) t = Translation(entry, []) -- William Leslie Notice: Likely much of this email is, by the nature of copyright, covered under copyright law. You absolutely MAY reproduce any part of it in accordance with the copyright law of the nation you are reading this in. Any attempt to DENY YOU THOSE RIGHTS would be illegal without prior contractual agreement.
participants (2)
-
Andrey Ayupov
-
William ML Leslie