Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit 14df8d4

Browse files
author
Mikhail Arkhipov
authored
Avoid empty node in empty global scope (#1226)
* Add null checks * Avoid null node in empty global scope * Remove unrelated change
1 parent 92ce32a commit 14df8d4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Analysis/Ast/Impl/Extensions/ScopeExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public static int GetBodyStartIndex(this IScope scope) {
2727
return cd.HeaderIndex;
2828
case FunctionDefinition fd:
2929
return fd.HeaderIndex;
30+
case null:
31+
return 0;
3032
default:
3133
return scope.Node.StartIndex;
3234
}

src/Analysis/Ast/Impl/Values/Scope.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ public EmptyGlobalScope(IPythonModule module) {
126126
}
127127
public IPythonModule Module { get; }
128128
public string Name => string.Empty;
129-
public ScopeStatement Node => null;
129+
public ScopeStatement Node => Module.Analysis.Ast;
130130
public IScope OuterScope => null;
131-
public IGlobalScope GlobalScope { get; protected set; }
131+
public IGlobalScope GlobalScope { get; }
132132
public IReadOnlyList<IScope> Children => Array.Empty<IScope>();
133133
public IEnumerable<IScope> EnumerateTowardsGlobal => Enumerable.Repeat(this, 1);
134134
public IEnumerable<IScope> EnumerateFromGlobal => Enumerable.Repeat(this, 1);

0 commit comments

Comments
 (0)