From 4d2d22e486ebb02659678750d0f04b632a615a9e Mon Sep 17 00:00:00 2001 From: redxef Date: Wed, 18 Dec 2024 01:20:36 +0100 Subject: [PATCH] fix: allow passing builtins to functions. --- Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs | 3 +++ Tests/Tests.cs | 1 + 2 files changed, 4 insertions(+) diff --git a/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs b/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs index 5ca8df6..7027c09 100644 --- a/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs +++ b/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs @@ -503,6 +503,9 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp { switch (expression) { case Symbol s: if (_environment.Find(s.Name()) is not IEnvironment env) { + if (builtins.ContainsKey(s.Name()) || builtinsLater.ContainsKey(s.Name())) { + return s; + } throw new ApplicationException($"Could not find '{s.Name()}'"); } var r_ = env.Get(s.Name()); diff --git a/Tests/Tests.cs b/Tests/Tests.cs index 3f358d1..1b4714d 100644 --- a/Tests/Tests.cs +++ b/Tests/Tests.cs @@ -258,6 +258,7 @@ namespace Tests //Assert.Equal("", e.eval("(rand)").ToString()); //Assert.Equal("", e.eval("(shuf (list 0 1 2 3 4 5 6))").ToString()); Assert.Equal("(1 2 3 4 5 6 7)", e.eval("(qsort (lambda (a b) (> a b)) '(5 4 7 3 2 6 1))").ToString()); + Assert.Equal("(1 2 3 4 5 6 7)", e.eval("(qsort > (list 5 4 7 3 2 6 1))").ToString()); } } }