Fixed false positive for 'yield' expressions in lambdas (PY-11663)

This commit is contained in:
Andrey Vlasovskikh
2014-05-23 20:46:56 +04:00
parent 5de561b885
commit 99c6577bd7
3 changed files with 7 additions and 1 deletions

View File

@@ -33,7 +33,7 @@ public class ReturnAnnotator extends PyAnnotator {
public void visitPyYieldExpression(final PyYieldExpression node) {
final ScopeOwner owner = ScopeUtil.getScopeOwner(node);
if (!(owner instanceof PyFunction)) {
if (!(owner instanceof PyFunction || owner instanceof PyLambdaExpression)) {
getHolder().createErrorAnnotation(node, "'yield' outside of function");
}
}

View File

@@ -0,0 +1 @@
g = lambda: (yield 10)

View File

@@ -114,6 +114,11 @@ public class PythonHighlightingTest extends PyTestCase {
public void testYieldInDefaultValue() {
doTest(LanguageLevel.PYTHON34, true, false);
}
// PY-11663
public void testYieldInLambda() {
doTest();
}
public void testImportStarAtTopLevel() {
doTest(true, false);