This is getting messy, but now the same sym can reference multiple
places. (. file references mysym) only holds the last one, but
(. file definitions <x> :referenced-by) could still hold older
references.
Ideally, any time you write:
(local x (<some form with compiler error>))
(print x)
I don't want it to say "unknown variable x". To make sure that's the
case, I need to do as much error recovery as possible. I don't have full
error recovery, but I've got the common cases, and I'm working down the
fennel.friends list
That was a tough one to debug! I almost thought it was a bug in fennel,
but it, of course, turned out to be a fennel-ls problem.
When you have a symbol like (foo:bar), fennel compiles it by
"macroexpanding" it to (: foo :bar). When fennel macroexpands a macro,
it tries to clean up the output by giving it a best-guess
bytestart/byteend. Fennel-ls was picking up *both* the accurate
`foo:bar` sym and the best-guess virtual `foo` sym as separate
references to `foo`. When computing the renames, the best-guess values
were getting used, which made the replacement range inaccurate.
Although it was properly handled it before, there were no tests for
the unicode offset conversions that used characters that are 3 bytes
in utf8 and 2 bytes in utf16, so I added one. Now, every single
""type"" of charater is tested.
there should now be no cases where multivals and table destructures are
confused. ie, (local [_ x] (values 1 2)) and (local (_ x) [1 2]) are recognized
as nonsense.
Now unused variables and var-not-set lints use a different system.
References are now of type:
{:symbol sym :target ast :ref-type (or :read :write :mutate)}
instead of ast.
unused var will warn if all the references are :write references.