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
ae67505e
Commit
ae67505e
authored
Sep 05, 2020
by
da-woods
Committed by
GitHub
Sep 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow cast to ctuple (GH-3812)
parent
fd1a431b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
+17
-3
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+6
-3
tests/run/ctuple.pyx
tests/run/ctuple.pyx
+11
-0
No files found.
Cython/Compiler/Parsing.py
View file @
ae67505e
...
...
@@ -316,9 +316,12 @@ def p_typecast(s):
s
.
next
()
base_type
=
p_c_base_type
(
s
)
is_memslice
=
isinstance
(
base_type
,
Nodes
.
MemoryViewSliceTypeNode
)
is_template
=
isinstance
(
base_type
,
Nodes
.
TemplatedTypeNode
)
is_const_volatile
=
isinstance
(
base_type
,
Nodes
.
CConstOrVolatileTypeNode
)
if
not
is_memslice
and
not
is_template
and
not
is_const_volatile
and
base_type
.
name
is
None
:
is_other_unnamed_type
=
isinstance
(
base_type
,
(
Nodes
.
TemplatedTypeNode
,
Nodes
.
CConstOrVolatileTypeNode
,
Nodes
.
CTupleBaseTypeNode
,
))
if
not
(
is_memslice
or
is_other_unnamed_type
)
and
base_type
.
name
is
None
:
s
.
error
(
"Unknown type"
)
declarator
=
p_c_declarator
(
s
,
empty
=
1
)
if
s
.
sy
==
'?'
:
...
...
tests/run/ctuple.pyx
View file @
ae67505e
...
...
@@ -142,6 +142,17 @@ cpdef (int, double) cpdef_ctuple_return_type(int x, double y):
return
x
,
y
def
cast_to_ctuple
(
*
o
):
"""
>>> cast_to_ctuple(1, 2.)
(1, 2.0)
"""
cdef
int
x
cdef
double
y
x
,
y
=
<
(
int
,
double
)
>
o
return
x
,
y
@
cython
.
infer_types
(
True
)
def
test_type_inference
():
"""
...
...
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