sibyl icon indicating copy to clipboard operation
sibyl copied to clipboard

Do not emit warnings for underscored arguments

Open florius0 opened this issue 2 years ago • 4 comments

When using @decorate trace(), warnings for underscored arguments are emitted, however these arguments are not being used in the function itself:

# ...
  @decorate trace()
  def index(conn, _params) do
    small_fish = find_fish()
    large_fish = find_fish("large")

    json(conn, small_fish ++ large_fish)
  end
# ...

Will result in warning: the underscored variable "_params" is used after being set. A leading underscore indicates that the value of the variable should be ignored. If this is intended please rename the variable to remove the underscore

Probably can be fixed with generated: true in quotes

florius0 avatar Sep 10 '23 01:09 florius0

This is actually a limitation in the decorator library we're using I believe :disappointed:

We're actually working on an experimental replacement for the decorator library which won't emit these warnings.

Another limitation is that you may need to add unnecessary function heads to set default arguments at times.

Will continue working on this and keep you posted!

vereis avatar Sep 11 '23 14:09 vereis

Ahoy all! I've just pushed a PR containing a new Sibyl.Experimental module which should give us the ability to trace functions without needed to run into the pitfalls of the decorator library we're currently using.

Usage should generally be similar:

use Sibyl.Experimental

@sibyl trace: true
def my_function do
  :ok
end

Or

use Sibyl.Experimental, trace_all: true

Any thoughts would be much appreciated: https://github.com/Vetspire/sibyl/pull/35!

vereis avatar Jan 22 '24 12:01 vereis

I see this was supposedly solved here: https://github.com/Vetspire/sibyl/pull/23 Why are we still seeing the issue here?

Note: I am on the latest Sibyl and experiencing major issue compiling functions with unused argument

APB9785 avatar Apr 15 '24 18:04 APB9785

EDIT: the issue was actually caused by Sibyl not getting updated properly, it was conflicting with opentelemetry_process_propagator and ended up running an old version from before that PR was released. With a manual conflict resolution, I was able to get Sibyl on the latest update for real, and the issue is resolved. 🙂

for anyone else with the same issue:

  • mix deps.unlock sibyl
  • mix deps.unlock opentelemetry_process_propagator
  • set {:sibyl, "~> 0.1.9"} in mix.exs
  • mix deps.get

APB9785 avatar Apr 15 '24 19:04 APB9785