Skip to content

Commit 8d58ac6

Browse files
committed
Bug fix: NullReferenceException when args was null.
1 parent 41149cd commit 8d58ac6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Analysis/Ast/Impl/Types/Collections/PythonCollectionType.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ bool isMutable
5757
public override PythonMemberType MemberType => PythonMemberType.Class;
5858
public override IMember GetMember(string name) => name == @"__iter__" ? IteratorType : base.GetMember(name);
5959

60-
public override IMember CreateInstance(IArgumentSet args)
61-
=> new PythonCollection(this, args.Arguments.Select(a => a.Value).OfType<IMember>().ToArray());
60+
public override IMember CreateInstance(IArgumentSet args) {
61+
var contents = args?.Arguments == null
62+
? Array.Empty<IMember>() :
63+
args.Arguments.Select(a => a.Value).OfType<IMember>().ToArray();
64+
return new PythonCollection(this, contents);
65+
}
6266

6367
public override IMember Call(IPythonInstance instance, string memberName, IArgumentSet args)
6468
=> DeclaringModule.Interpreter.GetBuiltinType(TypeId)?.Call(instance, memberName, args);

0 commit comments

Comments
 (0)