fix: allow passing builtins to functions.

This commit is contained in:
redxef 2024-12-18 01:20:36 +01:00
parent c9d7f1ee60
commit 4d2d22e486
Signed by: redxef
GPG key ID: 7DAC3AA211CBD921
2 changed files with 4 additions and 0 deletions

View file

@ -503,6 +503,9 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp {
switch (expression) {
case Symbol s:
if (_environment.Find(s.Name()) is not IEnvironment<string, Expression> 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());

View file

@ -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());
}
}
}