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 with forgotten cdef in extern ctypedef class #2744

Open
jdemeyer opened this Issue Dec 4, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@jdemeyer
Contributor

jdemeyer commented Dec 4, 2018

cdef extern from *:
    ctypedef class FOO.BAR [object FooObject]:
        int *foo

gives


Error compiling Cython file:
------------------------------------------------------------
...
cdef extern from *:
    ctypedef class FOO.BAR [object FooObject]:
        int *foo
           ^
------------------------------------------------------------

crash.pyx:3:12: Compiler crash in OptimizeBuiltinCalls

ModuleNode.body = StatListNode(crash.pyx:1:5)
StatListNode.stats[0] = CDefExternNode(crash.pyx:1:5)
CDefExternNode.body = StatListNode(crash.pyx:2:4)
StatListNode.stats[0] = CClassDefNode(crash.pyx:2:4,
    as_name = u'BAR',
    class_name = u'BAR',
    module_name = u'FOO',
    objstruct_name = u'FooObject',
    typedef_flag = 1)
CClassDefNode.body = StatListNode(crash.pyx:3:12)
StatListNode.stats[0] = ExprStatNode(crash.pyx:3:12)
ExprStatNode.expr = MulNode(crash.pyx:3:12,
    infix = True,
    operator = u'*',
    result_is_used = True,
    use_managed_ref = True)

Compiler crash traceback from this point on:
  File "Cython/Compiler/Visitor.py", line 180, in Cython.Compiler.Visitor.TreeVisitor._visit
    return handler_method(obj)
  File "Cython/Compiler/Visitor.py", line 531, in Cython.Compiler.Visitor.MethodDispatcherTransform.visit_BinopNode
    return self._visit_binop_node(node)
  File "Cython/Compiler/Visitor.py", line 545, in Cython.Compiler.Visitor.MethodDispatcherTransform._visit_binop_node
    if obj_type.is_builtin_type:
AttributeError: 'NoneType' object has no attribute 'is_builtin_type'

It turns out that int *foo should be cdef int *foo but the error message could be improved...

Without the pointer (just using int foo), one gets a proper error

Error compiling Cython file:
------------------------------------------------------------
...
cdef extern from *:
    ctypedef class FOO.BAR [object FooObject]:
        int foo
           ^
------------------------------------------------------------

crash.pyx:3:12: Syntax error in simple statement list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment