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

References broken on elixir 1.10 #75

Closed
lukaszsamson opened this issue Jan 9, 2020 · 4 comments
Closed

References broken on elixir 1.10 #75

lukaszsamson opened this issue Jan 9, 2020 · 4 comments

Comments

@lukaszsamson
Copy link
Collaborator

Mix.Tasks.Xref.calls/0 is deprecated now and does not seem to work correctly. We should probably migrate to compiler tracing

@josevalim
Copy link

josevalim commented Jan 11, 2020

Can you please expand on what "does not seem to work correctly" means? We kept a shim for users where it should work for functions (but not macros).

@lukaszsamson
Copy link
Collaborator Author

lukaszsamson commented Jan 12, 2020

@josevalim in https://github.com/lukaszsamson/elixir_xfer_repro repo I created a few modules to test xref behavior.
Below is the result of calling Mix.Tasks.Xref.calls/0 on 1.9 and 1.10

1.9.4

iex(1)> Mix.Tasks.Xref.calls() |> Enum.filter(fn %{callee: callee} -> callee == {XrefCalls.Callee, :hello, 0} end)                                   
[
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls,
    file: "lib/callee.ex",
    line: 19
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls,
    file: "lib/callee.ex",
    line: 15
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls,
    file: "lib/callee.ex",
    line: 14
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls,
    file: "lib/callee.ex",
    line: 13
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.SubmoduleCaller,
    file: "lib/callee.ex",
    line: 19
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.SubmoduleCaller,
    file: "lib/callee.ex",
    line: 15
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.SubmoduleCaller,
    file: "lib/callee.ex",
    line: 14
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.SubmoduleCaller,
    file: "lib/callee.ex",
    line: 13
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.CaptureCaller,
    file: "lib/capture_caller.ex",
    line: 7
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.ImportedCaller,
    file: "lib/imported_caller.ex",
    line: 9
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.ImportedCaller,
    file: "lib/imported_caller.ex",
    line: 8
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.ImportedCaller,
    file: "lib/imported_caller.ex",
    line: 7
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.Callee,
    file: "lib/callee.ex",
    line: 19
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.Callee,
    file: "lib/callee.ex",
    line: 15
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.Callee,
    file: "lib/callee.ex",
    line: 14
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.Callee,
    file: "lib/callee.ex",
    line: 13
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.DifferentLineCaller,
    file: "lib/different_line_caller.ex",
    line: 7
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.AliasedCaller,
    file: "lib/aliased_caller.ex",
    line: 9
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.AliasedCaller,
    file: "lib/aliased_caller.ex",
    line: 8
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.AliasedCaller,
    file: "lib/aliased_caller.ex",
    line: 7
  }
]

1.10-rc.0

iex(1)> Mix.Tasks.Xref.calls() |> Enum.filter(fn %{callee: callee} -> callee == {XrefCalls.Callee, :hello, 0} end)
[
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.SubmoduleCaller,
    file: "lib/callee.ex",
    line: 14
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.SubmoduleCaller,
    file: "lib/callee.ex",
    line: 13
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.SubmoduleCaller,
    file: "lib/callee.ex",
    line: 19
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.ImportedCaller,
    file: "lib/imported_caller.ex",
    line: nil
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.ImportedCaller,
    file: "lib/imported_caller.ex",
    line: nil
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.DifferentLineCaller,
    file: "lib/different_line_caller.ex",
    line: 7
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.AliasedCaller,
    file: "lib/aliased_caller.ex",
    line: 8
  },
  %{
    callee: {XrefCalls.Callee, :hello, 0},
    caller_module: XrefCalls.AliasedCaller,
    file: "lib/aliased_caller.ex",
    line: 7
  }
]

As you can see on 1.10

@josevalim
Copy link

josevalim commented Jan 12, 2020

Thanks, I have fixed those. Although note macros and others still won't show up, but calls/0 is at least a bit more accurate now!

@lukaszsamson
Copy link
Collaborator Author

Works again on elixir@9814a4cd61b9b054e4594c1b225d7939a9eb5add. I'm closing this now but #80 still remains relevant

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

No branches or pull requests

2 participants