Skip to content

Inconsistent compiler trace events for super calls and captures #14395

Closed
@lukaszsamson

Description

@lukaszsamson

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions