Skip to content
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 case clause matching when using IEx.break! #13133

Closed
deviprsd opened this issue Nov 21, 2023 · 8 comments
Closed

No case clause matching when using IEx.break! #13133

deviprsd opened this issue Nov 21, 2023 · 8 comments

Comments

@deviprsd
Copy link

deviprsd commented Nov 21, 2023

Elixir and Erlang/OTP versions

erlang 26.1.2
elixir 1.15.7 // or 1.15.7-otp-26

Operating system

MacOS

Current behavior

I'm setting a break point in iex -S mix phx.server, this is happening in a liveview process and while I'm using Ash, it might have to do more with elixir.

iex(2)> break! Data.Account.Space.Action.GetByCodename.read/4

When I trigger the break by opening the appropriate view, I'm getting this error.

** (CaseClauseError) no case clause matching: {:line, :infinity}
    (elixir 1.15.7) src/elixir.erl:250: :elixir.env_for_eval/1
    (iex 1.15.7) lib/iex/pry.ex:84: IEx.Pry.pry/2
    (iex 1.15.7) lib/iex/pry.ex:89: IEx.Pry.pry_with_next/3
    (data 0.1.0) Data.Account.Space.Action.GetByCodename.read/4
    (ash 2.17.3) lib/ash/actions/read.ex:2869: Ash.Actions.Read.run_query/6
    (ash 2.17.3) lib/ash/actions/read.ex:1449: anonymous fn/4 in Ash.Actions.Read.data_field/3
    (ash 2.17.3) lib/ash/engine/engine.ex:537: anonymous fn/2 in Ash.Engine.run_iteration/1
    (ash 2.17.3) lib/ash/engine/engine.ex:558: anonymous fn/4 in Ash.Engine.async/2

Module code,

defmodule Data.Account.Space.Action.GetByCodename do
  require Ash.Query
  use Ash.Resource.ManualRead

  def read(query, _data_layer_query, _opts, _context) do
    {:ok, []}
  end
end

Expected behavior

Not throw this error and enter pry session

@deviprsd deviprsd changed the title no case clause matching when using IEx.break! No case clause matching when using IEx.break! Nov 21, 2023
@josevalim
Copy link
Member

@deviprsd can you reproduce it outside of an Ash module? If you cannot, this may be an Ash bug, so I would appreciate help isolating the bug so it doesn't depend on Ash. Thank you!

@zachdaniel
Copy link
Contributor

It seems interesting…I’m not sure if any of our metaprogramming would come into play here as all we ultimately do is call that module. I agree though, Ash should be eliminated as a factor here, although I’m not sure how that could be done. What even produces {:line, :infinity}?

@zachdaniel
Copy link
Contributor

@deviprsd are you calling the action using the code interface? Perhaps trying using a query/api call directly if so.

@deviprsd
Copy link
Author

deviprsd commented Nov 22, 2023

@zachdaniel I'm using code interface, it looks something like this.

code_interface do
    define :get_by_codename, action: :by_codename, args: [...args]
end

read :by_codename do
    get? true
    # ...args
    manual GetByCodename
end

I tried this, still the same error.

Space |> Ash.Query.for_read(:by_codename, %{codename: id}) |> Data.Account.read()

@zachdaniel
Copy link
Contributor

So that eliminates any code generation as the culprit then. 🤔 try this. In iex do the following before trying to set your break: Code.ensure_compiled!(TheReadModule) (would type it out but I'm on my phone).

@deviprsd
Copy link
Author

deviprsd commented Nov 22, 2023

Well I'm guessing you mean my ManualRead module here, but just to be sure I did that for the api and resource as well

Code.ensure_compiled!(Data.Account.Space.Action.GetByCodename)
Code.ensure_compiled!(Data.Account.Space)
Code.ensure_compiled!(Data.Account)
break! Data.Account.Space.Action.GetByCodename.read/4

Same error

@zachdaniel
Copy link
Contributor

zachdaniel commented Nov 22, 2023

Here is a minimal reproduction not using any libraries at all.

If you uncomment the work/0 function that fixes both cases, so it seems like it has something to do with not knowing about compile time dependencies or something along those lines. Regardless, the break/0 function seems like it should be a supported use case? never mind, it breaks in both cases, false alarm.

So I don't have a working version of this actually. But the issue is pretty clearly reproduced I think.

Using this project, do the following in ex

iex(1)> break! AnAdopter.read
1
iex(2)> Break.break
** (CaseClauseError) no case clause matching: {:line, :infinity}
    (iex 1.15.4) lib/iex/pry.ex:84: IEx.Pry.pry/2
    (iex 1.15.4) lib/iex/pry.ex:89: IEx.Pry.pry_with_next/3
    (break 0.1.0) AnAdopter.read/0

https://github.com/zachdaniel/breakpoint-broken-example/blob/main/lib/break.ex

@josevalim
Copy link
Member

This minimal example is perfect and exactly what I needed. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants