mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
trailing comma after star parameter is a syntax error (PY-4039)
This commit is contained in:
@@ -138,6 +138,7 @@ public class FunctionParsing extends Parsing {
|
||||
}
|
||||
|
||||
boolean first = true;
|
||||
boolean afterStarParameter = false;
|
||||
while (myBuilder.getTokenType() != endToken) {
|
||||
if (first) {
|
||||
first = false;
|
||||
@@ -155,9 +156,16 @@ public class FunctionParsing extends Parsing {
|
||||
parseParameterSubList();
|
||||
continue;
|
||||
}
|
||||
boolean isStarParameter = atAnyOfTokens(PyTokenTypes.MULT, PyTokenTypes.EXP);
|
||||
if (!parseParameter(endToken, isLambda)) {
|
||||
if (afterStarParameter) {
|
||||
myBuilder.error("expression expected");
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (isStarParameter) {
|
||||
afterStarParameter = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (myBuilder.getTokenType() == endToken && endToken == PyTokenTypes.RPAR) {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
def some_function(*args,): # <- missing highlighting here
|
||||
pass
|
||||
|
||||
def some_function(**kwargs,): # <- missing highlighting here
|
||||
pass
|
||||
@@ -0,0 +1,42 @@
|
||||
PyFile:CommaAfterStarArg.py
|
||||
PyFunction('some_function')
|
||||
PsiElement(Py:DEF_KEYWORD)('def')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IDENTIFIER)('some_function')
|
||||
PyParameterList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PyNamedParameter('args')
|
||||
PsiElement(Py:MULT)('*')
|
||||
PsiElement(Py:IDENTIFIER)('args')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiErrorElement:expression expected
|
||||
<empty list>
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(Py:END_OF_LINE_COMMENT)('# <- missing highlighting here')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyStatementList
|
||||
PyPassStatement
|
||||
PsiElement(Py:PASS_KEYWORD)('pass')
|
||||
PsiWhiteSpace('\n\n')
|
||||
PyFunction('some_function')
|
||||
PsiElement(Py:DEF_KEYWORD)('def')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IDENTIFIER)('some_function')
|
||||
PyParameterList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PyNamedParameter('kwargs')
|
||||
PsiElement(Py:EXP)('**')
|
||||
PsiElement(Py:IDENTIFIER)('kwargs')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiErrorElement:expression expected
|
||||
<empty list>
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(Py:END_OF_LINE_COMMENT)('# <- missing highlighting here')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyStatementList
|
||||
PyPassStatement
|
||||
PsiElement(Py:PASS_KEYWORD)('pass')
|
||||
@@ -310,6 +310,10 @@ public class PythonParsingTest extends ParsingTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testCommaAfterStarArg() { // PY-4039
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void doTest() {
|
||||
doTest(LanguageLevel.PYTHON25);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user