From b0a554a39896e9cd2fedadcbfa32bba7052c8057 Mon Sep 17 00:00:00 2001 From: Christopher Wilcox Date: Thu, 6 Aug 2015 13:57:04 -0700 Subject: [PATCH 1/3] Fixes #688 by Handling null _vars _vars was being set to null in at least on spot (ModuleAnalysis 455). Now it is set as an empty list in cases where it could come as null. --- Python/Product/Analysis/MemberResult.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Python/Product/Analysis/MemberResult.cs b/Python/Product/Analysis/MemberResult.cs index 94142e55a9..154d17a941 100644 --- a/Python/Product/Analysis/MemberResult.cs +++ b/Python/Product/Analysis/MemberResult.cs @@ -29,7 +29,7 @@ public struct MemberResult { internal MemberResult(string name, IEnumerable vars) { _name = _completion = name; - _vars = () => vars; + _vars = () => vars ?? Empty; _type = null; _type = GetMemberType; } @@ -42,7 +42,7 @@ public MemberResult(string name, PythonMemberType type) { internal MemberResult(string name, string completion, IEnumerable vars, PythonMemberType? type) { _name = name; - _vars = () => vars; + _vars = () => vars ?? Empty; _completion = completion; if (type != null) { _type = () => type.Value; @@ -54,7 +54,8 @@ internal MemberResult(string name, string completion, IEnumerable internal MemberResult(string name, Func> vars, Func type) { _name = _completion = name; - _vars = vars; + Func> empty = () => Empty; + _vars = vars ?? empty; _type = type; } From 393a44210abd1ac80ff64d70fa9551d13e0636a9 Mon Sep 17 00:00:00 2001 From: Christopher Wilcox Date: Fri, 7 Aug 2015 13:53:29 -0700 Subject: [PATCH 2/3] #688 add debug fail and handle null to member result --- Python/Product/Analysis/ModuleAnalysis.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Python/Product/Analysis/ModuleAnalysis.cs b/Python/Product/Analysis/ModuleAnalysis.cs index 9ce84ecb6d..f7b7336c8e 100644 --- a/Python/Product/Analysis/ModuleAnalysis.cs +++ b/Python/Product/Analysis/ModuleAnalysis.cs @@ -451,8 +451,8 @@ public IEnumerable GetDefinitionTree(SourceLocation location) { .Select(s => new MemberResult(s.Name, s.GetMergedAnalysisValues())) .ToList(); } catch (Exception) { - // TODO: log exception - return new[] { new MemberResult("Unknown", null) }; + Debug.Fail("Failed to find scope. Bad state in analysis"); + return new[] { new MemberResult("Unknown", new AnalysisValue[] { }) }; } } From 4843e8fdc1f05a71dee4bcdfc0e6d22b1d55230e Mon Sep 17 00:00:00 2001 From: Christopher Wilcox Date: Fri, 21 Aug 2015 14:41:27 -0700 Subject: [PATCH 3/3] #688 Add back a todo statement that was removed --- Python/Product/Analysis/ModuleAnalysis.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Python/Product/Analysis/ModuleAnalysis.cs b/Python/Product/Analysis/ModuleAnalysis.cs index f7b7336c8e..6b0c3eafdf 100644 --- a/Python/Product/Analysis/ModuleAnalysis.cs +++ b/Python/Product/Analysis/ModuleAnalysis.cs @@ -451,6 +451,7 @@ public IEnumerable GetDefinitionTree(SourceLocation location) { .Select(s => new MemberResult(s.Name, s.GetMergedAnalysisValues())) .ToList(); } catch (Exception) { + // TODO: log exception Debug.Fail("Failed to find scope. Bad state in analysis"); return new[] { new MemberResult("Unknown", new AnalysisValue[] { }) }; }