mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed false negative in parsing incomplete 'raise ... from' expression (PY-6734)
This commit is contained in:
@@ -340,7 +340,9 @@ public class StatementParsing extends Parsing implements ITokenTypeRemapper {
|
||||
}
|
||||
else if (myBuilder.getTokenType() == PyTokenTypes.FROM_KEYWORD) {
|
||||
myBuilder.advanceLexer();
|
||||
getExpressionParser().parseSingleExpression(false);
|
||||
if (!getExpressionParser().parseSingleExpression(false)) {
|
||||
myBuilder.error("Expression expected");
|
||||
}
|
||||
}
|
||||
}
|
||||
checkEndOfStatement(inSuite);
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
def f():
|
||||
raise AttributeError from
|
||||
@@ -0,0 +1,20 @@
|
||||
PyFile:RaiseFromNoExpr.py
|
||||
PyFunction('f')
|
||||
PsiElement(Py:DEF_KEYWORD)('def')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IDENTIFIER)('f')
|
||||
PyParameterList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyStatementList
|
||||
PyRaiseStatement
|
||||
PsiElement(Py:RAISE_KEYWORD)('raise')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: AttributeError
|
||||
PsiElement(Py:IDENTIFIER)('AttributeError')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FROM_KEYWORD)('from')
|
||||
PsiErrorElement:Expression expected
|
||||
<empty list>
|
||||
@@ -328,6 +328,11 @@ public class PythonParsingTest extends ParsingTestCase {
|
||||
doTest(LanguageLevel.PYTHON33);
|
||||
}
|
||||
|
||||
// PY-6734
|
||||
public void testRaiseFromNoExpr() {
|
||||
doTest(LanguageLevel.PYTHON30);
|
||||
}
|
||||
|
||||
public void doTest() {
|
||||
doTest(LanguageLevel.PYTHON25);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user