Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
8bca56b
Fix #668 (partial)
Mar 1, 2019
a731c2a
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 1, 2019
069910b
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 5, 2019
7ffc9db
Tests
Mar 5, 2019
6303c45
Revert "Tests"
Mar 5, 2019
945451c
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 5, 2019
034e437
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 5, 2019
f997d68
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 6, 2019
0e4ff95
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 11, 2019
878c8c5
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 13, 2019
35e1033
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 13, 2019
1073711
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 14, 2019
86028da
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 14, 2019
4d4bca7
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 18, 2019
ac04f76
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 18, 2019
bab03da
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 20, 2019
85ec685
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 27, 2019
be7466d
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 28, 2019
01781c0
Exp
Mar 27, 2019
f544f8a
Limit concurrency
Mar 28, 2019
01bd719
Concurrency limit
Mar 28, 2019
2f8e564
Drop cache after analysis
Mar 28, 2019
9a933bd
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 28, 2019
4ad56bb
Fix regression
Mar 28, 2019
c280c55
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 3, 2019
b21b8b8
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 7, 2019
babaee4
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 8, 2019
092efd6
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 8, 2019
b97594d
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 10, 2019
2a50eb9
Fix test
Apr 10, 2019
9c7f58d
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 10, 2019
00faa5f
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 12, 2019
4c8aa92
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 12, 2019
1a67bc8
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 12, 2019
7a13215
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 16, 2019
3d907d8
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 16, 2019
96a1924
Exclude empty names
Apr 17, 2019
4620786
PR feedback
Apr 17, 2019
5197370
Do not walk node twice
Apr 17, 2019
11a8a2c
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 17, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ internal void ProcessComprehension(Comprehension node) {
var value = GetValueFromExpression(cfor.List);
if (value != null) {
switch (cfor.Left) {
case NameExpression nex when value is IPythonCollection coll:
DeclareVariable(nex.Name, coll.GetIterator().Next, VariableSource.Declaration, nex);
case NameExpression nex when value is IPythonCollection c1:
DeclareVariable(nex.Name, c1.GetIterator().Next, VariableSource.Declaration, nex);
break;
case NameExpression nex:
DeclareVariable(nex.Name, UnknownType, VariableSource.Declaration, nex);
Expand All @@ -156,6 +156,12 @@ internal void ProcessComprehension(Comprehension node) {
DeclareVariable(item.Name, UnknownType, VariableSource.Declaration, item);
}
break;
case TupleExpression tex when value is IPythonCollection c2 && tex.Items.Count > 0:
var iter = c2.GetIterator();
foreach (var item in tex.Items.OfType<NameExpression>().Where(x => !string.IsNullOrEmpty(x.Name))) {
DeclareVariable(item.Name, iter.Next, VariableSource.Declaration, item);
}
break;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override bool Walk(DictionaryComprehension node) {
foreach (var iter in node.Iterators) {
iter?.Walk(ew);
}
return true;
return false;
}

private NameCollectorWalker CollectNames(Comprehension c) {
Expand Down
11 changes: 11 additions & 0 deletions src/Analysis/Ast/Test/LintUndefinedVarsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,17 @@ public async Task NoLeakFromComprehension() {
d[0].SourceSpan.Should().Be(2, 33, 2, 34);
}

[TestMethod, Priority(0)]
public async Task NestedDictComprehension() {
const string code = @"
dmap = {}
sizes = {}
x = {srv:sum([sizes[d] for d in dbs]) for srv, dbs in dmap.items()}
";
var d = await LintAsync(code);
d.Should().BeEmpty();
}

private async Task<IReadOnlyList<DiagnosticsEntry>> LintAsync(string code, InterpreterConfiguration configuration = null) {
var analysis = await GetAnalysisAsync(code, configuration ?? PythonVersions.LatestAvailable3X);
var a = Services.GetService<IPythonAnalyzer>();
Expand Down