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
c17bdb28
Commit
c17bdb28
authored
Oct 31, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disallow fused lambdas (doesn't make sense) & fix fused def in normal classes
parent
bfc6469a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
5 deletions
+24
-5
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-1
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+8
-2
tests/errors/e_fused_closure.pyx
tests/errors/e_fused_closure.pyx
+2
-2
tests/errors/fused_types.pyx
tests/errors/fused_types.pyx
+3
-0
tests/run/fused_types.pyx
tests/run/fused_types.pyx
+10
-0
No files found.
Cython/Compiler/Nodes.py
View file @
c17bdb28
...
@@ -2540,7 +2540,7 @@ def __pyx_fused_cpdef(signatures, args, kwargs):
...
@@ -2540,7 +2540,7 @@ def __pyx_fused_cpdef(signatures, args, kwargs):
py_func
.
doc
=
orig_py_func
.
doc
py_func
.
doc
=
orig_py_func
.
doc
# ... and the symbol table
# ... and the symbol table
del
env
.
entries
[
'__pyx_fused_cpdef'
]
env
.
entries
.
pop
(
'__pyx_fused_cpdef'
,
None
)
if
is_def
:
if
is_def
:
env
.
entries
[
e
.
name
]
=
e
env
.
entries
[
e
.
name
]
=
e
else
:
else
:
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
c17bdb28
...
@@ -1383,6 +1383,7 @@ if VALUE is not None:
...
@@ -1383,6 +1383,7 @@ if VALUE is not None:
"""
)
"""
)
fused_function
=
None
fused_function
=
None
in_lambda
=
0
def
__call__
(
self
,
root
):
def
__call__
(
self
,
root
):
self
.
env_stack
=
[
root
.
scope
]
self
.
env_stack
=
[
root
.
scope
]
...
@@ -1403,8 +1404,10 @@ if VALUE is not None:
...
@@ -1403,8 +1404,10 @@ if VALUE is not None:
return
node
return
node
def
visit_LambdaNode
(
self
,
node
):
def
visit_LambdaNode
(
self
,
node
):
self
.
in_lambda
+=
1
node
.
analyse_declarations
(
self
.
env_stack
[
-
1
])
node
.
analyse_declarations
(
self
.
env_stack
[
-
1
])
self
.
visitchildren
(
node
)
self
.
visitchildren
(
node
)
self
.
in_lambda
-=
1
return
node
return
node
def
visit_ClassDefNode
(
self
,
node
):
def
visit_ClassDefNode
(
self
,
node
):
...
@@ -1458,9 +1461,12 @@ if VALUE is not None:
...
@@ -1458,9 +1461,12 @@ if VALUE is not None:
body
=
Nodes
.
PassStatNode
(
node
.
pos
))
body
=
Nodes
.
PassStatNode
(
node
.
pos
))
if
node
.
has_fused_arguments
:
if
node
.
has_fused_arguments
:
if
self
.
fused_function
:
if
self
.
fused_function
or
self
.
in_lambda
:
if
self
.
fused_function
not
in
self
.
fused_error_funcs
:
if
self
.
fused_function
not
in
self
.
fused_error_funcs
:
error
(
node
.
pos
,
"Cannot nest fused functions"
)
if
self
.
in_lambda
:
error
(
node
.
pos
,
"Fused lambdas not allowed"
)
else
:
error
(
node
.
pos
,
"Cannot nest fused functions"
)
self
.
fused_error_funcs
.
add
(
self
.
fused_function
)
self
.
fused_error_funcs
.
add
(
self
.
fused_function
)
# env.declare_var(node.name, PyrexTypes.py_object_type, node.pos)
# env.declare_var(node.name, PyrexTypes.py_object_type, node.pos)
...
...
tests/errors/e_fused_closure.pyx
View file @
c17bdb28
...
@@ -18,7 +18,7 @@ def generator(cython.integral i):
...
@@ -18,7 +18,7 @@ def generator(cython.integral i):
_ERRORS
=
u"""
_ERRORS
=
u"""
e_fused_closure.pyx:6:4: Cannot nest fused functions
e_fused_closure.pyx:6:4: Cannot nest fused functions
e_fused_closure.pyx:10:11:
Cannot nest fused functions
e_fused_closure.pyx:10:11:
Fused lambdas not allowed
e_fused_closure.pyx:14:15:
Cannot nest fused functions
e_fused_closure.pyx:14:15:
Fused lambdas not allowed
e_fused_closure.pyx:16:0: Fused generators not supported
e_fused_closure.pyx:16:0: Fused generators not supported
"""
"""
tests/errors/fused_types.pyx
View file @
c17bdb28
...
@@ -36,6 +36,8 @@ ctypedef fused memslice_dtype_t:
...
@@ -36,6 +36,8 @@ ctypedef fused memslice_dtype_t:
def
f
(
memslice_dtype_t
[:,
:]
a
):
def
f
(
memslice_dtype_t
[:,
:]
a
):
pass
pass
lambda
cython
.
integral
i
:
i
# This is all valid
# This is all valid
dtype5
=
fused_type
(
int
,
long
,
float
)
dtype5
=
fused_type
(
int
,
long
,
float
)
dtype6
=
cython
.
fused_type
(
int
,
long
)
dtype6
=
cython
.
fused_type
(
int
,
long
)
...
@@ -61,4 +63,5 @@ fused_types.pyx:28:16: Call with wrong number of arguments (expected 2, got 1)
...
@@ -61,4 +63,5 @@ fused_types.pyx:28:16: Call with wrong number of arguments (expected 2, got 1)
fused_types.pyx:29:16: Call with wrong number of arguments (expected 2, got 3)
fused_types.pyx:29:16: Call with wrong number of arguments (expected 2, got 3)
fused_types.pyx:30:4: Keyword and starred arguments not allowed in cdef functions.
fused_types.pyx:30:4: Keyword and starred arguments not allowed in cdef functions.
fused_types.pyx:36:6: Invalid base type for memoryview slice: int *
fused_types.pyx:36:6: Invalid base type for memoryview slice: int *
fused_types.pyx:39:0: Fused lambdas not allowed
"""
"""
tests/run/fused_types.pyx
View file @
c17bdb28
...
@@ -210,3 +210,13 @@ def test_opt_args():
...
@@ -210,3 +210,13 @@ def test_opt_args():
opt_args
[
int
,
float
](
3
,
4.0
)
opt_args
[
int
,
float
](
3
,
4.0
)
opt_args
[
int
,
double
](
3
,
4.0
)
opt_args
[
int
,
double
](
3
,
4.0
)
class
NormalClass
(
object
):
def
method
(
self
,
cython
.
integral
i
):
print
cython
.
typeof
(
i
),
i
def
test_normal_class
():
"""
>>> test_normal_class()
short 10
"""
NormalClass
().
method
[
pure_cython
.
short
](
10
)
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