This repository was archived by the owner on Apr 14, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
src/Analysis/Ast/Impl/Modules Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -406,15 +406,20 @@ public void NotifyAnalysisBegins() {
406406 // In all variables find those imported, then traverse imported modules
407407 // and remove references to this module. If variable refers to a module,
408408 // recurse into module but only process global scope.
409+
410+ if ( GlobalScope == null ) {
411+ return ;
412+ }
413+
414+ // TODO: Figure out where the nulls below are coming from.
409415 var importedVariables = ( ( IScope ) GlobalScope )
410- . TraverseDepthFirst ( c => c . Children )
411- . ExcludeDefault ( )
412- . SelectMany ( s => s . Variables )
413- . Where ( v => v . Source == VariableSource . Import ) ;
416+ . TraverseDepthFirst ( c => c ? . Children ?? Enumerable . Empty < IScope > ( ) )
417+ . SelectMany ( s => s ? . Variables ?? VariableCollection . Empty )
418+ . Where ( v => v ? . Source == VariableSource . Import ) ;
414419
415420 foreach ( var v in importedVariables ) {
416421 v . RemoveReferences ( this ) ;
417- if ( v . Value is IPythonModule module ) {
422+ if ( v . Value is IPythonModule module ) {
418423 RemoveReferencesInModule ( module ) ;
419424 }
420425 }
You can’t perform that action at this time.
0 commit comments