Commit bcdcd9fb authored by Stefan Behnel's avatar Stefan Behnel

Improve error message for mixing return type declarations into def function syntax.

See #2529.
parent 7bebbddd
......@@ -3370,7 +3370,11 @@ def p_def_statement(s, decorators=None, is_async_def=False):
s.enter_async()
s.next()
name = _reject_cdef_modifier_in_py(s, p_ident(s))
s.expect('(')
s.expect(
'(',
"Expected '(', found '%s'. Did you use cdef syntax in a Python declaration? "
"Use decorators and Python type annotations instead." % (
s.systring if s.sy == 'IDENT' else s.sy))
args, star_arg, starstar_arg = p_varargslist(s, terminator=')')
s.expect(')')
_reject_cdef_modifier_in_py(s, s.systring)
......
......@@ -13,10 +13,15 @@ def nogil func() -> int:
def func() nogil:
pass
def inline int* func():
pass
_ERRORS = u"""
4:11: Cannot use cdef modifier 'inline' in Python function signature. Use a decorator instead.
7:8: Cannot use cdef modifier 'api' in Python function signature. Use a decorator instead.
10:10: Cannot use cdef modifier 'nogil' in Python function signature. Use a decorator instead.
13:11: Cannot use cdef modifier 'nogil' in Python function signature. Use a decorator instead.
16:11: Cannot use cdef modifier 'inline' in Python function signature. Use a decorator instead.
16:14: Expected '(', found '*'. Did you use cdef syntax in a Python declaration? Use decorators and Python type annotations instead.
"""
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment