Linter false-positive? on setting named function to the table

Linting the following code with Fennel's linter produces the "unused local foo" error:

(fn x [g] (set g.f (fn foo [])))

While the function name is indeed unused in the function itself, the compiled Lua clearly uses it:

local function x(g)
  local function foo()
  g.f = foo
  return nil

Noticed that with one of my macros that generate functions with user-specified body, so I can't just omit the name in the macro, as it may be used for recursion.

Assigned to
1 year, 2 months ago
3 months ago
No labels applied.

~technomancy 1 year, 2 months ago

I think in this case when the user wants to enable this linting but doesn't want to use the name, they should pick a name that starts with an underscore.

~technomancy REPORTED CLOSED 3 months ago

Given how much better fennel-ls is than src/linter.fnl, and the fact that it can be used in batch mode without any LSP involved I think it's best if we consider the latter to be included as an example of how to write a plugin, and not concern ourselves too much with how good it is at linting.

Register here or Log in to comment, or comment via email.