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
Gwenaël Samain
cython
Commits
47deba00
Commit
47deba00
authored
Dec 06, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix for-in loop variable inference after enabling list/tuple item type inference
parent
8352b902
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
5 deletions
+15
-5
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+5
-3
Cython/Compiler/TypeInference.py
Cython/Compiler/TypeInference.py
+3
-2
tests/run/listcomp.pyx
tests/run/listcomp.pyx
+7
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
47deba00
...
@@ -2489,9 +2489,11 @@ class NextNode(AtomicExprNode):
...
@@ -2489,9 +2489,11 @@ class NextNode(AtomicExprNode):
return
item_type
return
item_type
else
:
else
:
# Avoid duplication of complicated logic.
# Avoid duplication of complicated logic.
fake_index_node
=
IndexNode
(
self
.
pos
,
fake_index_node
=
IndexNode
(
base
=
self
.
iterator
.
sequence
,
self
.
pos
,
index
=
IntNode
(
self
.
pos
,
value
=
'0'
))
base
=
self
.
iterator
.
sequence
,
index
=
IntNode
(
self
.
pos
,
value
=
'PY_SSIZE_T_MAX'
,
type
=
PyrexTypes
.
c_py_ssize_t_type
))
return
fake_index_node
.
infer_type
(
env
)
return
fake_index_node
.
infer_type
(
env
)
def
analyse_types
(
self
,
env
):
def
analyse_types
(
self
,
env
):
...
...
Cython/Compiler/TypeInference.py
View file @
47deba00
...
@@ -136,8 +136,9 @@ class MarkParallelAssignments(EnvTransform):
...
@@ -136,8 +136,9 @@ class MarkParallelAssignments(EnvTransform):
# object type when the base type cannot be handled.
# object type when the base type cannot be handled.
self
.
mark_assignment
(
target
,
ExprNodes
.
IndexNode
(
self
.
mark_assignment
(
target
,
ExprNodes
.
IndexNode
(
node
.
pos
,
node
.
pos
,
base
=
sequence
,
base
=
sequence
,
index
=
ExprNodes
.
IntNode
(
node
.
pos
,
value
=
'0'
)))
index
=
ExprNodes
.
IntNode
(
target
.
pos
,
value
=
'PY_SSIZE_T_MAX'
,
type
=
PyrexTypes
.
c_py_ssize_t_type
)))
self
.
visitchildren
(
node
)
self
.
visitchildren
(
node
)
return
node
return
node
...
...
tests/run/listcomp.pyx
View file @
47deba00
...
@@ -46,6 +46,13 @@ def inferred_type():
...
@@ -46,6 +46,13 @@ def inferred_type():
"""
"""
print
[
cython
.
typeof
(
obj
)
for
obj
in
[
A
(),
A
(),
A
()]]
print
[
cython
.
typeof
(
obj
)
for
obj
in
[
A
(),
A
(),
A
()]]
def
not_inferred_type
():
"""
>>> not_inferred_type()
['Python object', 'Python object', 'Python object']
"""
print
[
cython
.
typeof
(
obj
)
for
obj
in
[
1
,
A
(),
'abc'
]]
def
iterdict
():
def
iterdict
():
"""
"""
>>> iterdict()
>>> iterdict()
...
...
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