Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit 54eafdc

Browse files
authored
Open class scope when getting value from ctor (microsoft#926)
Found in microsoft#923. Is there an easy way to test this, or is this alright as-is?
1 parent c0f34ef commit 54eafdc

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Analysis/Ast/Impl/Analyzer/Evaluation/ExpressionEval.Callables.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,13 @@ public IMember GetValueFromClassCtor(IPythonClassType cls, CallExpression expr)
8989
var args = ArgumentSet.Empty;
9090
var init = cls.GetMember<IPythonFunctionType>(@"__init__");
9191
if (init != null) {
92-
var a = new ArgumentSet(init, 0, new PythonInstance(cls), expr, Module, this);
93-
if (a.Errors.Count > 0) {
94-
// AddDiagnostics(Module.Uri, a.Errors);
92+
using (OpenScope(cls.DeclaringModule, cls.ClassDefinition, out _)) {
93+
var a = new ArgumentSet(init, 0, new PythonInstance(cls), expr, Module, this);
94+
if (a.Errors.Count > 0) {
95+
// AddDiagnostics(Module.Uri, a.Errors);
96+
}
97+
args = a.Evaluate();
9598
}
96-
args = a.Evaluate();
9799
}
98100
return cls.CreateInstance(cls.Name, args);
99101
}

0 commit comments

Comments
 (0)