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
Xavier Thompson
cython
Commits
35ef5e01
Commit
35ef5e01
authored
Apr 18, 2020
by
da-woods
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix and test "type in fused_type" special-case
parent
879774e5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+5
-0
tests/run/fused_types.pyx
tests/run/fused_types.pyx
+31
-0
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
35ef5e01
...
...
@@ -3279,7 +3279,12 @@ class ReplaceFusedTypeChecks(VisitorTransform):
def
visit_PrimaryCmpNode
(
self
,
node
):
with
Errors
.
local_errors
(
ignore
=
True
):
type1
=
node
.
operand1
.
analyse_as_type
(
self
.
local_scope
)
# type2 should not be specialized here as a special case
# we always want to check against the global fused type
fused_to_specific
=
self
.
local_scope
.
fused_to_specific
self
.
local_scope
.
fused_to_specific
=
None
type2
=
node
.
operand2
.
analyse_as_type
(
self
.
local_scope
)
self
.
local_scope
.
fused_to_specific
=
fused_to_specific
if
type1
and
type2
:
false_node
=
ExprNodes
.
BoolNode
(
node
.
pos
,
value
=
False
)
...
...
tests/run/fused_types.pyx
View file @
35ef5e01
...
...
@@ -21,6 +21,7 @@ ctypedef double *p_double
ctypedef
int
*
p_int
fused_type3
=
cython
.
fused_type
(
int
,
double
)
fused_composite
=
cython
.
fused_type
(
fused_type2
,
fused_type3
)
just_float
=
cython
.
fused_type
(
float
)
def
test_pure
():
"""
...
...
@@ -453,3 +454,33 @@ def test_cdef_func_with_const_fused_arg():
cdef
int
arg1
=
1
cdef
float
arg2
=
2.0
cdef
_func_const_fused_arg
(
arg0
,
&
arg1
,
&
arg2
)
cdef
in_check_1
(
just_float
x
):
return
just_float
in
floating
cdef
in_check_2
(
just_float
x
,
floating
y
):
# the "floating" on the right-hand side of the in statement should not be specialized
# - the test should still work.
return
just_float
in
floating
cdef
in_check_3
(
floating
x
):
# the floating on the left-hand side of the in statement should be specialized
# but the one of the right-hand side should not (so that the test can still work).
return
floating
in
floating
def
test_fused_in_check
():
"""
It should be possible to use fused types on in "x in ...fused_type" statements
even if that type is specialized in the function.
>>> test_fused_in_check()
True
True
True
True
"""
print
(
in_check_1
(
1.0
))
print
(
in_check_2
(
1.0
,
2.0
))
print
(
in_check_2
[
float
,
double
](
1.0
,
2.0
))
print
(
in_check_3
[
float
](
1.0
))
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