Commit 582aca53 authored by Marius Wachtler's avatar Marius Wachtler

support yield statements inside lambdas

parent 93243be1
......@@ -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:
......
......@@ -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);
......
......@@ -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())
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment