Repository navigation
Special case known good names for use-before-def - #429
Jake Bailey (jakebailey) wants to merge 1 commit into
Conversation
|
This can happen when builtins module is not loaded/scraped, which would be a big problem in many other cases. Members are assigned in the if (boolType != null) {
_members["True"] = _members["False"] = new AstPythonConstant(boolType);
}This can be a threading issue such as code analyzed before builtins are loaded |
|
Well, if you think there's a better way to approach this, I'd be curious to see what you think about the test case for My previous fix to ignore |
|
Might be falling to fallback in var moduleRef = await Modules.TryImportAsync(_builtinName, token).ConfigureAwait(false);
if (moduleRef != null) {
_builtinModule = (BuiltinModule)moduleRef.Module;
} else {
_builtinModule = new BuiltinModule(fallback, this);
Modules.SetModule(_builtinName, BuiltinModule);
} |
|
On the if (typeId == BuiltinTypeId.NoneType) {
noneType = m as IPythonType;
}
...
_members["None"] = new AstPythonConstant(noneType); |
|
Doing that does actually fix that Generator test (and is way less hacky), but I'm not exactly sure where how to approach finding how the analysis for builtins doesn't happen before the rest of the diagnostics happens. |
|
Closing in favor of #447 for the |
Fixes microsoft#442. Replaces microsoft#429, which only masks the underlying True/False bug in microsoft#391. I also removed the hack in microsoft#336 which checked for `ConstantExpression`.
Fixes #391.
Sort of a hack, but these hardcoded names are pulled from the list of atoms in the Python grammar. I've still been unable to reproduce True/False being use-before-def (other than once without a debugger attached), but it shouldn't occur given that I now explicitly ignore them.
Unfortunately, this may mask a bug in
ProjectState.BuiltinModule.GetMember, since I don't think there's a good reason whyNoneshould fail to be found...