Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
582aca53
Commit
582aca53
authored
Aug 13, 2015
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support yield statements inside lambdas
parent
93243be1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
2 deletions
+8
-2
src/codegen/codegen.cpp
src/codegen/codegen.cpp
+1
-1
src/core/cfg.cpp
src/core/cfg.cpp
+1
-1
test/tests/generators.py
test/tests/generators.py
+6
-0
No files found.
src/codegen/codegen.cpp
View file @
582aca53
...
...
@@ -73,13 +73,13 @@ SourceInfo::SourceInfo(BoxedModule* m, ScopingAnalysis* scoping, FutureFlags fut
switch
(
ast
->
type
)
{
case
AST_TYPE
:
:
ClassDef
:
case
AST_TYPE
:
:
Lambda
:
case
AST_TYPE
:
:
Module
:
case
AST_TYPE
:
:
Expression
:
case
AST_TYPE
:
:
Suite
:
is_generator
=
false
;
break
;
case
AST_TYPE
:
:
FunctionDef
:
case
AST_TYPE
:
:
Lambda
:
is_generator
=
containsYield
(
ast
);
break
;
default:
...
...
src/core/cfg.cpp
View file @
582aca53
...
...
@@ -1178,7 +1178,7 @@ private:
push_back
(
makeExpr
(
new
AST_LangPrimitive
(
AST_LangPrimitive
::
UNCACHE_EXC_INFO
)));
if
(
root_type
!=
AST_TYPE
::
FunctionDef
)
if
(
root_type
!=
AST_TYPE
::
FunctionDef
&&
root_type
!=
AST_TYPE
::
Lambda
)
raiseExcHelper
(
SyntaxError
,
"'yield' outside function"
);
return
makeLoad
(
node_name
,
node
);
...
...
test/tests/generators.py
View file @
582aca53
...
...
@@ -128,3 +128,9 @@ try:
g
.
next
()
except
Exception
as
e
:
print
type
(
e
),
e
# StopIteration
x
=
lambda
:
(
yield
1
)
print
list
(
x
())
x
=
lambda
:
((
yield
1
),
(
yield
2
))
print
list
(
x
())
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