mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
Fixes PY-253: foo[1]=2 now has foo as reference, not target
This commit is contained in:
@@ -257,6 +257,11 @@ public class ExpressionParsing extends Parsing {
|
||||
else {
|
||||
checkMatches(PyTokenTypes.RBRACKET, message("PARSE.expected.rbracket"));
|
||||
expr.done(PyElementTypes.SUBSCRIPTION_EXPRESSION);
|
||||
if (first_identifier_is_target) {
|
||||
recast_first_identifier = true; // subscription is always a reference
|
||||
expr.rollbackTo();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
expr = expr.precede();
|
||||
@@ -265,6 +270,7 @@ public class ExpressionParsing extends Parsing {
|
||||
expr.drop();
|
||||
break;
|
||||
}
|
||||
recast_first_identifier = false; // it is true only after a break; normal flow always unsets it.
|
||||
}
|
||||
}
|
||||
while (recast_first_identifier);
|
||||
|
||||
1
python/testData/psi/SubscribedAssignmentLHS.py
Normal file
1
python/testData/psi/SubscribedAssignmentLHS.py
Normal file
@@ -0,0 +1 @@
|
||||
a[1] = 2
|
||||
14
python/testData/psi/SubscribedAssignmentLHS.txt
Normal file
14
python/testData/psi/SubscribedAssignmentLHS.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
PyFile:SubscribedAssignmentLHS.py(0,8)
|
||||
PyAssignmentStatement(0,8)
|
||||
PySubscriptionExpression(0,4)
|
||||
PyReferenceExpression: a(0,1)
|
||||
PsiElement(Py:IDENTIFIER)('a')(0,1)
|
||||
PsiElement(Py:LBRACKET)('[')(1,2)
|
||||
PyNumericLiteralExpression(2,3)
|
||||
PsiElement(Py:INTEGER_LITERAL)('1')(2,3)
|
||||
PsiElement(Py:RBRACKET)(']')(3,4)
|
||||
PsiWhiteSpace(' ')(4,5)
|
||||
PsiElement(Py:EQ)('=')(5,6)
|
||||
PsiWhiteSpace(' ')(6,7)
|
||||
PyNumericLiteralExpression(7,8)
|
||||
PsiElement(Py:INTEGER_LITERAL)('2')(7,8)
|
||||
@@ -26,6 +26,10 @@ public class PythonParsingTest extends ParsingTestCase {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testSubscribedAssignmentLHS() throws Exception {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testConditionalParenLambda() throws Exception {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user