Skip to content

Commit

Permalink
SONARPY-1830 Prevent single-assigned module scope types from being pr…
Browse files Browse the repository at this point in the history
…opagated to nested functions
  • Loading branch information
guillaume-dequenne-sonarsource committed May 14, 2024
1 parent 66d496f commit 6b08403
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def calling_global_func():

def using_nonlocal_var():
nonlocal some_nonlocal_var
some_nonlocal_var() # Noncompliant
some_nonlocal_var() # OK


def reassigned_function():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ public void visitName(Name name) {
.filter(Expression.class::isInstance)
.map(Expression.class::cast)
.map(Expression::typeV2)
// FIXME: classes and functions should be propagated like other types
.filter(t -> (t instanceof ClassType) || (t instanceof FunctionType))
.ifPresent(type -> setTypeToName(name, type));
}

Expand Down

0 comments on commit 6b08403

Please sign in to comment.