Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit 8b7dbe3

Browse files
author
Mikhail Arkhipov
authored
Merge pull request #118 from MikhailArkhipov/master
Fix References_Parameters_NestedFunction
2 parents 12fe3b3 + 5dfb67d commit 8b7dbe3

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

src/Analysis/Engine/Impl/ModuleAnalysis.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,14 @@ public VariablesResult GetVariables(Expression expr, SourceLocation location, st
229229
}
230230

231231
if (expr is NameExpression name) {
232-
var defScope = scope.EnumerateTowardsGlobal.FirstOrDefault(s =>
233-
s.ContainsVariable(name.Name) && (s == scope || s.VisibleToChildren || IsFirstLineOfFunction(scope, s, location)));
234-
235-
if (defScope == null) {
236-
variables = _unit.State.BuiltinModule.GetDefinitions(name.Name)
237-
.SelectMany(ToVariables);
232+
if (!scope.EnumerateTowardsGlobal.Any()) {
233+
variables = _unit.State.BuiltinModule.GetDefinitions(name.Name).SelectMany(ToVariables);
238234
} else {
239-
variables = GetVariablesInScope(name, defScope).Distinct();
235+
foreach (var defScope in scope.EnumerateTowardsGlobal
236+
.Where(s => s.ContainsVariable(name.Name) && (s == scope || s.VisibleToChildren || IsFirstLineOfFunction(scope, s, location)))) {
237+
var scopeVariables = GetVariablesInScope(name, defScope).Distinct();
238+
variables = variables.Union(scopeVariables);
239+
}
240240
}
241241
} else if (expr is MemberExpression member && !string.IsNullOrEmpty(member.Name)) {
242242
var objects = eval.Evaluate(member.Target);

src/Analysis/Engine/Test/AnalysisTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3120,7 +3120,6 @@ not abc
31203120
}
31213121

31223122
[TestMethod, Priority(0)]
3123-
[Ignore("https://github.com/Microsoft/python-language-server/issues/39")]
31243123
public async Task References_Parameters_NestedFunction() {
31253124
var uri = TestData.GetDefaultModuleUri();
31263125
using (var server = await CreateServerAsync(PythonVersions.LatestAvailable2X)) {

0 commit comments

Comments
 (0)