-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
no function clause matching in Gradient.ElixirExpr.pp_guards/1 #171
Labels
bug
Something isn't working
Comments
Thanks for the report! From a quick look it seems we're missing a clause for used-defined guards. We'll take a look at this. |
#145 (comment) seems to be related. |
I manage to get a small reproducible case that might be related to this @spec indirection(number(), number(), non_neg_integer()) ::
list({atom(), list(), binary()})
def indirection(storage, key, order) do
[:hi, [<<2>>], <<4>>]
end
@spec crash() :: number()
def crash() do
order = 2
key = 5
with {:atomic, [{_, [^order, ^key | 0], value}]} <- indirection(order, key, order) do
2 + 5
end
end calling lib/project/storage.ex: The atom on line 289 is expected to have type {atom(), list(), binary()} but it has type :hi
287 list({atom(), list(), binary()})
288 def indirection(storage, key, order) do
289 [:hi, [<<2>>], <<4>>]
290 end
291
lib/project/storage.ex: ** (FunctionClauseError) no function clause matching in Gradient.ElixirExpr.pp_cons/1
The following arguments were given to Gradient.ElixirExpr.pp_cons/1:
# 1
{:integer, 299, 0}
Attempted function clauses (showing 3 out of 3):
defp pp_cons({:cons, _, h, {nil, _}})
defp pp_cons({:cons, _, h, {:var, _, _} = v})
defp pp_cons({:cons, _, h, t})
(gradient 0.1.0) Gradient.ElixirExpr.pp_cons/1
(gradient 0.1.0) lib/gradient/elixir_expr.ex:491: Gradient.ElixirExpr.pp_cons/1
(gradient 0.1.0) lib/gradient/elixir_expr.ex:68: Gradient.ElixirExpr.pp_expr/1
(elixir 1.15.5) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2
(elixir 1.15.5) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2
(gradient 0.1.0) lib/gradient/elixir_expr.ex:158: Gradient.ElixirExpr.pp_expr/1
(gradient 0.1.0) lib/gradient/elixir_expr.ex:68: Gradient.ElixirExpr.pp_expr/1
(elixir 1.15.5) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 I've noticed that I can fix the crash by changing the code to the following @spec crash() :: number()
def crash() do
order = 2
key = 5
zero = 0
with {:atomic, [{_, [^order, ^key | ^zero], value}]} <- indirection(order, key, order) do
2 + 5
end
end the | 0 for some reason is causing issues |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I've been really enjoying using gradient, thank you for the work! I've encountered this error today when running
mix gradient
The error occurs three times within the same module and nowhere else. I believe that the issue stems from my custom guard which is used in three different functions.
Here is the guard definition
And here is an example of it in use
The text was updated successfully, but these errors were encountered: