From bbc6ec4d6229606ebf2807f538403ace38969355 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Tue, 25 Feb 2025 01:26:07 -0800 Subject: [PATCH] Improve selflint results by fixing a few mistakes. But selflint still does not pass. This appears to be due to bugs: src/fennel-ls/searcher.fnl:9:10: unknown field: path-sep src/fennel-ls.fnl:44:2: unknown field: table.unpack The first one is a pretty clear issue with the field being exported from fennel-ls.utils but somehow not picked up; reason is unclear. The second is due to the macroexpansion of `case` making reference to `table.unpack`, but I think it should be suppressed because the unknown global is not in this code; it's in the macro. Once these get fixed, we can add selflint to the ci target. --- flsproject.fnl | 3 ++- src/fennel-ls/analyzer.fnl | 1 - src/fennel-ls/compiler.fnl | 2 +- src/fennel-ls/docs.fnl | 12 ++++++++---- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/flsproject.fnl b/flsproject.fnl index 8c1c20a..24381e7 100644 --- a/flsproject.fnl +++ b/flsproject.fnl @@ -1 +1,2 @@ -{:fennel-path "./?.fnl;./?/init.fnl;src/?.fnl;src/?/init.fnl;deps/?.fnl;deps/?/init.fnl"} +{:lua-version "intersection" + :fennel-path "./?.fnl;./?/init.fnl;src/?.fnl;src/?/init.fnl;deps/?.fnl;deps/?/init.fnl"} diff --git a/src/fennel-ls/analyzer.fnl b/src/fennel-ls/analyzer.fnl index a1b3eab..ff016a8 100644 --- a/src/fennel-ls/analyzer.fnl +++ b/src/fennel-ls/analyzer.fnl @@ -42,7 +42,6 @@ find the definition `10`, but if `opts.stop-early?` is set, it would find (local utils (require :fennel-ls.utils)) (local files (require :fennel-ls.files)) (local docs (require :fennel-ls.docs)) -(local {: view} (require :fennel)) (local get-ast-info utils.get-ast-info) diff --git a/src/fennel-ls/compiler.fnl b/src/fennel-ls/compiler.fnl index 7e96d2e..abfed64 100644 --- a/src/fennel-ls/compiler.fnl +++ b/src/fennel-ls/compiler.fnl @@ -25,7 +25,7 @@ identifiers are declared / referenced in which places." (λ ast->macro-ast [ast] [(fennel.list (sym :eval-compiler) - ((or table.unpack _G.unpack) ast))]) + ((or (. table :unpack) _G.unpack) ast))]) (λ multisym? [t] ;; check if t is a symbol with multiple parts, eg. foo.bar.baz diff --git a/src/fennel-ls/docs.fnl b/src/fennel-ls/docs.fnl index 812e245..4a92cf4 100644 --- a/src/fennel-ls/docs.fnl +++ b/src/fennel-ls/docs.fnl @@ -13,10 +13,10 @@ name {:binding name :metadata (. METADATA value)})) (local lua-versions - {:lua51 (require :fennel-ls.docs.generated.lua51) - :lua52 (require :fennel-ls.docs.generated.lua52) - :lua53 (require :fennel-ls.docs.generated.lua53) - :lua54 (require :fennel-ls.docs.generated.lua54)}) + {:lua51 (require :fennel-ls.docs.generated.lua51) + :lua52 (require :fennel-ls.docs.generated.lua52) + :lua53 (require :fennel-ls.docs.generated.lua53) + :lua54 (require :fennel-ls.docs.generated.lua54)}) (fn get-lua-version [version] (when (not (. lua-versions version)) @@ -26,6 +26,10 @@ table.sort))))) (. lua-versions version)) +;; work around a mistake in Lua's own manual +(set lua-versions.lua51.package.fields.config + lua-versions.lua52.package.fields.config) + (set lua-versions.intersection (collect [k v (pairs lua-versions.lua51)] (if (. lua-versions.lua54 k) (values k v))))