Skip to content

Commit

Permalink
Syntax Error with case None. #PyDev-1232
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Aug 19, 2023
1 parent de41a7d commit 7222122
Show file tree
Hide file tree
Showing 12 changed files with 959 additions and 843 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ public abstract class AbstractScopeAnalyzerVisitor extends VisitorBase {

private final Set<String> builtinTokens = new HashSet<String>();

protected int isInMatchScope = 0;

public AbstractScopeAnalyzerVisitor(IPythonNature nature, String moduleName, IModule current, IDocument document,
IProgressMonitor monitor) {
this.monitor = monitor;
Expand Down Expand Up @@ -650,7 +652,10 @@ public Object visitName(Name node) throws Exception {
|| node.ctx == Name.KwOnlyParam
|| (node.ctx == Name.AugStore && found)) { //if it was undefined on augstore, we do not go on to creating the token
String rep = token.getRepresentation();
if (checkCurrentScopeForAssignmentsToBuiltins()) {
if (checkCurrentScopeForAssignmentsToBuiltins() &&
// In match scope we don't want to report assignment to builtin
// as something as: `match None:` is valid.
this.isInMatchScope == 0) {
if (builtinTokens.contains(rep)) {
// Overriding builtin...
onAddAssignmentToBuiltinMessage(token, rep);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,15 @@ public Object visitCompare(Compare node) throws Exception {
public void traverse(match_caseType node) throws Exception {
checkStop();
isInTestScope += 1;
isInMatchScope += 1;
if (node.pattern != null) {
node.pattern.accept(this);
}
if (node.guard != null) {
node.guard.accept(this);
}
isInTestScope -= 1;
isInMatchScope -= 1;
if (node.body != null) {
for (SimpleNode n : node.body) {
if (n != null) {
Expand Down
Loading

0 comments on commit 7222122

Please sign in to comment.