Skip to content

Potentially confusing behavior of dbg in main #14279

@sabiwara

Description

@sabiwara

Elixir and Erlang/OTP versions

Main branch

Operating system

n/a

Current behavior

Since we changed dbg to print intermediate results addressing #14005, the header and value can end up completely separated when the evaluated expression emits its own nested dbg:

defmodule Baz do
  def foo(x), do: dbg(x)
  def bar(x), do: foo(x) |> dbg()
end
iex> A.bar(1)
[iex:1: A.bar/1]
[iex:1: A.foo/1]
x #=> 1

foo(x) #=> 1

Expected behavior

In 1.18:

iex> A.bar(1)
[iex:1: A.foo/1]
x #=> 1

[iex:1: A.bar/1]
foo(x) #=> 1

The new behavior is arguably confusing, but I'm not sure if this can be fixed without reverting to the old approach - this might be a trade-off?

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