Open bcardarella opened 7 months ago
This is on Elixir 1.16
I tested this using the the stylesheet repo's MockSheet
. On my end, the error shows up at ~SHEET"""
(also 1.16)
This might be unavoidable based on Jose's response to this issue: https://github.com/elixir-lang/elixir/issues/8605.
~SHEET
is syntactic sugar for a sigil_SHEET("...")
and any warning generated inside the macro will be located at the caller.
I'll need to investigate why the warning shows up on line 5 instead of on the ~SHEET
on line 4 for the SwiftUI parser.
can't we get he location of ~SHEET
and count \n
s for location offsets?
My point here is not that it is difficult to for the parser to generate the error, it's that the Elixir compile might not support accurate locations on macro code.
If we can suppress the Elixir compiler warning, then we can generate our own.
By the way, this is based on some quick research on compiler warnings. I'll continue to look into it when I get some time.
One more idea is to set generated: true
for the quote
that generates the warning:
:generated - marks the given chunk as generated so it does not emit warnings. It is also useful to avoid dialyzer reporting errors when macros generate unused clauses. https://hexdocs.pm/elixir/Kernel.SpecialForms.html#quote/2
The :line
options might also be useful, but the conversation I linked to earlier (https://github.com/elixir-lang/elixir/issues/8605) makes me believe it would only affect the runtime code and not the compiler warnings
we don't want to be emitting warnings in the build, I would have thought that the LOC offsets would be sufficient here
LOC offsets
What do we do with the offsets? We know from the tests that the unused variable already has the correct line in its metadata. What more can we do?
I'll review it later.
Using the following stylesheet:
and I get the following error:
the warning should be reported for the 2nd block, not the first.