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
fd728734
Commit
fd728734
authored
Aug 16, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X allow coercion only from the same component types
parent
482e38c4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
4 deletions
+29
-4
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+11
-4
tests/errors/e_cpp_ctuple.pyx
tests/errors/e_cpp_ctuple.pyx
+18
-0
No files found.
Cython/Compiler/PyrexTypes.py
View file @
fd728734
...
...
@@ -4063,10 +4063,16 @@ class CTupleType(CType):
return
True
def
assignable_from_resolved_type
(
self
,
src_type
):
if
src_type
.
is_cpp_class
and
src_type
.
cname
==
"std::pair"
and
len
(
src_type
.
templates
)
==
2
:
# XXX len self.xxx == len src_type.templates
# XXX types are assignable
# (X,Y) can be assigned from std::pair[X,Y]
if
src_type
.
is_cpp_class
and
src_type
.
cname
==
"std::pair"
:
if
not
(
len
(
self
.
components
)
==
len
(
src_type
.
templates
)
==
2
):
return
False
for
(
c_dst
,
c_src
)
in
zip
(
self
.
components
,
src_type
.
templates
):
if
not
c_dst
.
same_as
(
c_src
):
return
False
return
True
"""
print
#from Cython.Compiler.Pipeline import dumptree
#dumptree(src_type)
...
...
@@ -4075,7 +4081,8 @@ class CTupleType(CType):
print src_type.cname
print src_type.templates
print
return
1
# XXX check types match
return 1 # XXX check types are the same
"""
return
super
(
CTupleType
,
self
).
assignable_from_resolved_type
(
src_type
)
...
...
tests/errors/e_cpp_ctuple.pyx
0 → 100644
View file @
fd728734
# tag: cpp
# mode: error
from
libcpp.utility
cimport
pair
cdef
void
f
(
pair
[
int
,
double
]
pxy
)
nogil
:
cdef
int
x
=
pxy
cdef
(
int
,
double
,
int
)
xyz
=
pxy
# NOTE the following is also error, simplary to how (int, int) cannot be assigned from (int, double)
cdef
(
int
,
int
)
ixy
=
pxy
_ERRORS
=
u"""
7:17: Cannot assign type 'pair[int,double]' to 'int'
8:34: Cannot assign type 'pair[int,double]' to '(int, double, int)'
11:26: Cannot assign type 'pair[int,double]' to '(int, int)'
"""
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