Hi,

I've been doing some debugging. The problem here is that the cfunc
directive forces an AdjustDefByDirectives visit. This is ok for the f node
but not for the genexpr DefNode (i.e. node.body.stats[0].expr.args[0].def_node,
where node is the f node) which inherits the cfunc directive from f and is
also (but wrongly) transformed to a CFuncDefNode.

I'm not sure whether there is a valid use case for inheriting cfunc or not.
The current implementation just set the visitor directives attribute to the
directives in a CompilerDirectivesNode, so the same directives are active
for the entire recursive descent. An alternative is to look at
node.directives (when available) instead of visitor.directives, this in
cases for which directive inheritance is undesirable. Here [1] is a PR that
does what I've just described, but only for cfunc. I consider it a dirty
hack until more general criteria are discussed and adopted (for example, it
seems inconsistent to me doing this for cfunc and not for ccall).

Cheers
--
Carlos

[1] https://github.com/cython/cython/pull/459



On Fri, Oct 16, 2015 at 3:53 PM, Carlos Pita <carlosjosep...@gmail.com>
wrote:

> Hi,
>
> in cython 0.24.0a0 this:
>
> ----------
> import cython as cy
>
> @cy.cfunc
> def f(cats):
>     ''.join(c for c in cats)
> ----------
>
> fails to compile with: Compiler crash in AnalyseDeclarationsTransform.
>
> Nevertheless the following close variations do compile:
>
> ----------
> import cython as cy
>
> @cy.cfunc
> def f(cats):
>     ''.join([c for c in cats])
> ----------
>
> ----------
> cdef f(cats):
>     ''.join(c for c in cats)
> ----------
>
> Cheers
> --
> Carlos
>
>
>
_______________________________________________
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel

Reply via email to