Closed chriseyre2000 closed 2 years ago
Here is the sample code (from Community Garden):
def start() do Agent.start(fn -> %{} end) end
This is the warning generated:
When passing an existing function as an argument, make sure to capture it instead of creating a new anonymous function. # preferred: using capture notation &%{}/0 # discouraged: creating new anonymous functions fn -> %{}() end
I think I get what's going on
quote do %{} end # => {:%{}, [], []}
In the AST, %{} looks like a function. <<>> and {} do the same, and we have a way of dealing with those
%{}
<<>>
{}
https://github.com/exercism/elixir-analyzer/blob/57a3a64f697924d3b4bcdb928c3635f1e7ad3685/lib/elixir_analyzer/exercise_test/common_checks/function_capture.ex#L44
It should be an easy fix.
Here is the sample code (from Community Garden):
This is the warning generated: