Skip to content

Commit c4d3af1

Browse files
committed
Disallow annotating destructuring assignments
1 parent ffd232f commit c4d3af1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/PythonSSTNodeFactory.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ public SSTNode createAssignment(SSTNode[] lhs, SSTNode rhs, int start, int stop)
187187
}
188188

189189
public SSTNode createAnnAssignment(SSTNode lhs, SSTNode type, SSTNode rhs, int start, int end) {
190+
if (lhs instanceof CollectionSSTNode) {
191+
throw errors.raiseInvalidSyntax(source, createSourceSection(lhs.getStartOffset(), lhs.getEndOffset()), "only single target (not tuple) can be annotated");
192+
}
190193
declareVar(lhs);
191194
if (!scopeEnvironment.getCurrentScope().hasAnnotations()) {
192195
scopeEnvironment.getCurrentScope().setHasAnnotations(true);

0 commit comments

Comments
 (0)