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 ...@@ -73,13 +73,13 @@ SourceInfo::SourceInfo(BoxedModule* m, ScopingAnalysis* scoping, FutureFlags fut
switch (ast->type) { switch (ast->type) {
case AST_TYPE::ClassDef: case AST_TYPE::ClassDef:
case AST_TYPE::Lambda:
case AST_TYPE::Module: case AST_TYPE::Module:
case AST_TYPE::Expression: case AST_TYPE::Expression:
case AST_TYPE::Suite: case AST_TYPE::Suite:
is_generator = false; is_generator = false;
break; break;
case AST_TYPE::FunctionDef: case AST_TYPE::FunctionDef:
case AST_TYPE::Lambda:
is_generator = containsYield(ast); is_generator = containsYield(ast);
break; break;
default: default:
......
...@@ -1178,7 +1178,7 @@ private: ...@@ -1178,7 +1178,7 @@ private:
push_back(makeExpr(new AST_LangPrimitive(AST_LangPrimitive::UNCACHE_EXC_INFO))); 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"); raiseExcHelper(SyntaxError, "'yield' outside function");
return makeLoad(node_name, node); return makeLoad(node_name, node);
......
...@@ -128,3 +128,9 @@ try: ...@@ -128,3 +128,9 @@ try:
g.next() g.next()
except Exception as e: except Exception as e:
print type(e), e # StopIteration 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