Ticket #156 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

cpdef method w/ no self crashes cython

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

Description

Hello,

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

cdef class A:
    cpdef foo(): 
        pass

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/Main.py", line 728, in main
    result = compile(sources, options)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 705, in compile
    return compile_multiple(source, options)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 675, in compile_multiple
    result = run_pipeline(source, options)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 537, in run_pipeline
    err, enddata = context.run_pipeline(pipeline, source)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 196, in run_pipeline
    data = phase(data)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ParseTreeTransforms.py", line 595, in __call__
    return super(AnalyseDeclarationsTransform, self).__call__(root)
  File "Visitor.py", line 177, in Cython.Compiler.Visitor.CythonTransform.__call__ (/home/hoytak/sysroot/src/cython/Cython/Compiler/Visitor.c:2365)
  File "Visitor.py", line 163, in Cython.Compiler.Visitor.VisitorTransform.__call__ (/home/hoytak/sysroot/src/cython/Cython/Compiler/Visitor.c:2109)
  File "Visitor.py", 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/ParseTreeTransforms.py", line 598, in visit_ModuleNode
    node.analyse_declarations(self.env_stack[-1])
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ModuleNode.py", line 58, in analyse_declarations
    self.body.analyse_declarations(env)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 313, in analyse_declarations
    stat.analyse_declarations(env)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 2553, in analyse_declarations
    self.body.analyse_declarations(scope)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 313, in analyse_declarations
    stat.analyse_declarations(env)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", 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/Nodes.py", line 1291, in call_self_node
    self_arg = ExprNodes.NameNode(self.pos, name=arg_names[0])
IndexError: list index out of range

Thanks!

--Hoyt

Change History

Changed 5 years ago by dagss

  • milestone changed from wishlist to 0.11.1

Changed 5 years ago by dagss

  • priority changed from minor to major

Changed 5 years ago by scoder

Test added as -T156.

Changed 5 years ago by robertwb

  • owner changed from somebody to robertwb

Changed 5 years ago by robertwb

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