Spurious warning "Unused entry 'genexpr'" #1699

Open
mhsmith opened this Issue May 6, 2017 · 0 comments

Comments

Projects
None yet
1 participant

mhsmith commented May 6, 2017 edited

Cython version 0.25.2

l = [1,2,3]

def f():
    print(x for x in l)
$ cython -Wextra -Werror foo.pyx

Error compiling Cython file:
------------------------------------------------------------
...
l = [1,2,3]

def f():
    print(x for x in l)
           ^
------------------------------------------------------------

foo.pyx:4:12: Unused entry 'genexpr'

This only happens when the generator expression is in a function, rather than at the module level. Surrounding the expression with parentheses doesn't help. Converting it to a list comprehension does remove the warning, but will make performance worse, especially if the generator expression would not have run to completion.

I like to use -Wextra -Werror because the "unused" warnings often indicate a genuine error in my code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment