Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler crash in AnalyseExpressionsTransform #1752

Closed
vijairaj opened this issue Jun 27, 2017 · 1 comment
Closed

Compiler crash in AnalyseExpressionsTransform #1752

vijairaj opened this issue Jun 27, 2017 · 1 comment

Comments

@vijairaj
Copy link

I am using Cython 0.25.2 on Windows 7 (x64) and found Cython to be crashing when compiling a .py file.

Reduced test to reproduce the issue

class Number: zero = 0

def main():
    m1 = 1 + max(1, Number.zero)
    m2 = m1
    print m2

main()

Changes that makes the error disappear

  • If I change Number.zero to a local variable or a constant
  • If I change the order of parameters in max
  • If I remove m2 = m1

Stack trace

Error compiling Cython file:
------------------------------------------------------------
...
class Number: zero = 0

def main():
^
------------------------------------------------------------

cyerr.py:3:0: Compiler crash in AnalyseExpressionsTransform

ModuleNode.body = StatListNode(cyerr.py:1:0)
StatListNode.stats[1] = DefNode(cyerr.py:3:0,
    is_cyfunction = True,
    modifiers = [...]/0,
    name = u'main',
    py_wrapper_required = True,
    reqd_kw_flags_cname = '0',
    used = True)

Compiler crash traceback from this point on:
  File "Cython\Compiler\Visitor.py", line 180, in Cython.Compiler.Visitor.TreeVisitor._visit (C:\projects\cython-wheels\Cython\Cython\Compiler\Visitor.c:5261)
    return handler_method(obj)
  File "c:\python27\lib\site-packages\Cython\Compiler\ParseTreeTransforms.py", line 2008, in visit_FuncDefNode
    node.local_scope.infer_types()
  File "c:\python27\lib\site-packages\Cython\Compiler\Symtab.py", line 887, in infer_types
    get_type_inferer().infer_types(self)
  File "c:\python27\lib\site-packages\Cython\Compiler\TypeInference.py", line 454, in infer_types
    if not resolve_assignments(assignments):
  File "c:\python27\lib\site-packages\Cython\Compiler\TypeInference.py", line 419, in resolve_assignments
    infer_name_node_type(node)
  File "c:\python27\lib\site-packages\Cython\Compiler\TypeInference.py", line 401, in infer_name_node_type
    types, entry.might_overflow, entry.pos, scope)
  File "c:\python27\lib\site-packages\Cython\Compiler\TypeInference.py", line 523, in safe_spanning_type
    result_type = simply_type(reduce(find_spanning_type, types), pos)
  File "c:\python27\lib\site-packages\Cython\Compiler\TypeInference.py", line 509, in simply_type
    if result_type.is_reference:
AttributeError: 'NoneType' object has no attribute 'is_reference'
@scoder
Copy link
Contributor

scoder commented Jun 27, 2017

Thank you for this excellent bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants