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

Inconsistent compiler trace events for super calls and captures #14395

Closed
lukaszsamson opened this issue Apr 3, 2025 · 0 comments
Closed

Inconsistent compiler trace events for super calls and captures #14395

lukaszsamson opened this issue Apr 3, 2025 · 0 comments

Comments

@lukaszsamson
Copy link
Contributor

Elixir and Erlang/OTP versions

Erlang/OTP 27 [erts-15.2.3] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]

Elixir 1.18.3 (compiled with Erlang/OTP 27)

Operating system

any

Current behavior

Given a compile tracer

defmodule MyTracer do
  def trace(event, _env) do
    dbg(event)
    :ok
  end
end
Code.put_compiler_option(:tracers, [MyTracer])
  1. super call does not emit any events
defmodule OverFunCall do
  def fun(x) do
    1
  end

  defoverridable [fun: 1]

  def fun(x) do
    super(x)
  end
end
  1. &super/n capture does not emit any events
defmodule OverFunCapture1 do
  def fun(x) do
    1
  end

  defoverridable [fun: 1]

  def fun(x) do
    Enum.map([], &super/1)
  end
end
  1. &super(&1) call inside capture generates a local_function event
defmodule OverFunCapture2 do
  def fun(x) do
    1
  end

  defoverridable [fun: 1]

  def fun(x) do
    Enum.map([], &super(&1))
  end
end
[iex:12: MyTracer.trace/2]
event #=> {:local_function, [line: 9, column: 19], :"fun (overridable 1)", 1}
  1. For defmacro neither of the cases emits any events

Expected behavior

There is a couple of options here

  1. super emits consistent local_(function|macro) events in all cases - not ideal as it exposes not documented implementation detail :"fun (overridable 1)"
  2. no events emitted at all - not ideal as we emit local calls in other case
  3. A new event category super_(function|macro)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant