Skip to content

debug() buffer shows wrong function #415

@PeterPavicic

Description

@PeterPavicic

I encountered this issue after debugging a nested function in an apply loop, as recreated below.

After running apply(..., FUN = foo), the debug buffer which opens will always show foo() being debugged, even though the R is correctly debugging another function (bar() in the provided example).

This issue persists whether or not the debug buffer is closed after debugging foo().

foo <- function(n) {
  print("in foo()")
  resultFoo <- bar(2 * n)

  resultFoo
}

bar <- function(n) {
  print("in bar()")
  resultBar <- 3 * n

  resultBar
}

debug(foo)

apply(matrix(1:3, ncol = 1), MARGIN = 1, FUN = foo) # debugging buffer opened

# go through debugging and close debugging buffer

undebug(foo)
debug(bar)

bar(2) # debugging buffer for foo() opens up

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