From 8257acbfbb62461df46c02a4ea0f615527ef528d Mon Sep 17 00:00:00 2001 From: redxef Date: Thu, 7 Nov 2024 22:26:33 +0100 Subject: [PATCH] fix! method invocation if no arguments are supplied. --- Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs b/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs index 495c46a..371fbbd 100644 --- a/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs +++ b/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs @@ -182,13 +182,21 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp { private static Expression _invoke(IEnumerable args) { Object o = (Object) args.First(); String s = (String) args.Skip(1).First(); - Cons l = (Cons) args.Skip(2).First(); + IEnumerable l; + if (args.Skip(2).First() is Boolean lb && lb == Boolean.FALSE) { + l = new List(); + } else if (args.Skip(2).First() is Cons lc) { + l = lc.ToList(); + } else { + throw new ApplicationException($"Expected a list of arguments, got {args.Skip(2).First()}"); + } + IList r = new List(); MethodInfo? mi = o.Value().GetType().GetMethod(s.Value()); if (mi == null) { throw new ApplicationException($"{o.Value()} has not method {s.Value()}"); } - object?[]? l_ = l.ToList().Select(x => { + object?[]? l_ = l.Select(x => { switch (x) { case Integer s: return s.Value();