Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
271d2505
Commit
271d2505
authored
Aug 15, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Give a better parser error message when defining return type annotations on cdef functions.
See #2529.
parent
a7fec3e3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+8
-0
tests/errors/cdef_func_syntax.pyx
tests/errors/cdef_func_syntax.pyx
+13
-0
No files found.
Cython/Compiler/Parsing.py
View file @
271d2505
...
...
@@ -3255,6 +3255,14 @@ def p_c_func_or_var_declaration(s, pos, ctx):
is_const_method
=
1
else
:
is_const_method
=
0
if
s
.
sy
==
'->'
:
# Special enough to give a better error message and keep going.
s
.
error
(
"Return type annotation is not allowed in cdef/cpdef signatures. "
"Please define it before the function name, as in C signatures."
,
fatal
=
False
)
s
.
next
()
p_test
(
s
)
# Keep going, but ignore result.
if
s
.
sy
==
':'
:
if
ctx
.
level
not
in
(
'module'
,
'c_class'
,
'module_pxd'
,
'c_class_pxd'
,
'cpp_class'
)
and
not
ctx
.
templates
:
s
.
error
(
"C function definition not allowed here"
)
...
...
tests/errors/cdef_func_syntax.pyx
0 → 100644
View file @
271d2505
# mode: error
cdef
inline
func
()
->
int
:
pass
cpdef
inline
func
()
->
int
:
pass
_ERRORS
=
u"""
3:19: Return type annotation is not allowed in cdef/cpdef signatures. Please define it before the function name, as in C signatures.
6:20: Return type annotation is not allowed in cdef/cpdef signatures. Please define it before the function name, as in C signatures.
"""
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment