Opened 7 years ago

Closed 7 years ago

#156 closed defect (fixed)

cpdef method w/ no self crashes cython

Reported by: hoytak Owned by: robertwb
Priority: major Milestone: 0.11.1
Component: Parsing Keywords:



In version 1474:7f1b96cad687, the following code crashes the compiler:

cdef class A:
    cpdef foo(): 

Note that foo() should be foo(self). If you replace the cpdef with either def or cdef, the error is correctly reported and cython works fine. With the above code segment, however, we get the following error in addition to the error report:

Error converting Pyrex file to C:
cdef class A:
    cpdef foo():

/home/hoytak/workspace/cython-tests/paramstruct.pyx:2:10: C method has no self argument
Traceback (most recent call last):
  File "/home/hoytak/sysroot/bin/cython", line 8, in <module>
    main(command_line = 1)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/", line 728, in main
    result = compile(sources, options)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/", line 705, in compile
    return compile_multiple(source, options)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/", line 675, in compile_multiple
    result = run_pipeline(source, options)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/", line 537, in run_pipeline
    err, enddata = context.run_pipeline(pipeline, source)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/", line 196, in run_pipeline
    data = phase(data)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/", line 595, in __call__
    return super(AnalyseDeclarationsTransform, self).__call__(root)
  File "", line 177, in Cython.Compiler.Visitor.CythonTransform.__call__ (/home/hoytak/sysroot/src/cython/Cython/Compiler/Visitor.c:2365)
  File "", line 163, in Cython.Compiler.Visitor.VisitorTransform.__call__ (/home/hoytak/sysroot/src/cython/Cython/Compiler/Visitor.c:2109)
  File "", line 43, in Cython.Compiler.Visitor.BasicVisitor.visit (/home/hoytak/sysroot/src/cython/Cython/Compiler/Visitor.c:955)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/", line 598, in visit_ModuleNode
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/", line 58, in analyse_declarations
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/", line 313, in analyse_declarations
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/", line 2553, in analyse_declarations
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/", line 313, in analyse_declarations
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/", line 1262, in analyse_declarations
    py_func_body = self.call_self_node(is_module_scope = env.is_module_scope)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/", line 1291, in call_self_node
    self_arg = ExprNodes.NameNode(self.pos, name=arg_names[0])
IndexError: list index out of range



Change History (5)

comment:1 Changed 7 years ago by dagss

  • Milestone changed from wishlist to 0.11.1

comment:2 Changed 7 years ago by dagss

  • Priority changed from minor to major

comment:3 Changed 7 years ago by scoder

Test added as -T156.

comment:4 Changed 7 years ago by robertwb

  • Owner changed from somebody to robertwb

comment:5 Changed 7 years ago by robertwb

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.