On Thu, Jan 6, 2011 at 10:54 AM, Robert Bradshaw <[email protected]> wrote: > On Thu, Jan 6, 2011 at 10:48 AM, Vitja Makarov <[email protected]> > wrote: >> 2011/1/6 Robert Bradshaw <[email protected]>: >>> On Thu, Jan 6, 2011 at 10:30 AM, Stefan Behnel <[email protected]> wrote: >>>> Daniel Norberg, 06.01.2011 12:20: >>>>> I'm getting a curious error in Cython 0.14 when trying to compile this: >>>>> >>>>> def bar(foo): >>>>> qux = foo >>>>> quux = foo[qux.baz] >>>>> >>>>> The error message: >>>>> >>>>> $ cython bar.py >>>>> >>>>> Error compiling Cython file: >>>>> ------------------------------------------------------------ >>>>> ... >>>>> def bar(foo): >>>>> qux = foo >>>>> quux = foo[qux.baz] >>>>> ^ >>>>> ------------------------------------------------------------ >>>>> >>>>> /Users/daniel/Desktop/cython-test/bar.py:3:15: Object of type >>>>> '<unspecified>' has no attribute 'baz' >>>>> >>>>> Cython 0.13 compiles this just fine. I also tried the latest revision of >>>>> cython-devel (b816b03ff502) and it fails. >>>> >>>> I can reproduce this. From a quick test, it seems like the type inference >>>> machinery processes 'quux' and 'qux' in the wrong order, i.e. 'quux' before >>>> 'qux'. Anyone interested in taking a closer look? >>> >>> That shouldn't be happening, as it should know the inferred type of >>> quux depends on the inferred type of qux. I'll take a look. >>> >>> - Robert >>> _______________________________________________ >>> Cython-dev mailing list >>> [email protected] >>> http://codespeak.net/mailman/listinfo/cython-dev >>> >> >> Strange thing this code compiles: >> >> def bar(foo): >> qux = foo >> xquux = foo[qux.baz] >> >> but this doesn't: >> >> def bar(foo): >> qux = foo >> aquux = foo[qux.baz] > > Since it doesn't detect the dependency, half the time it'll get lucky > (probably as a function of the variable names).
The problem was that the indexing operator inference was changed to depend on the index type as well as the base type, but its type_dependencies method wasn't updated to reflect this. Thanks for catching that, fix at https://github.com/cython/cython/commit/43a3dbea06e00bf6eb6592017964b79e35bae2d6 - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
