Skip to content

Recursive and nested calls of rigged functions not displayed right #48

@moodymudskipper

Description

@moodymudskipper

Because of the way we store ..FIRST_CALL.. and ..EVALED_ARGS.. in the mask.

fake_package("fake", list(
  add2 = function(a, b) {
    a + b
  }, 
  add4 = function(a, b, c, d) {
    add2(a, b) + add2(c, d)
  },
  rec_factorial = function(x) {
    if(x == 1) return(1)
    x * rec_factorial(x-1)
  } 
))

rig_in_namespace(add2, add4, rec_factorial, print_args = TRUE)

# works
add4(1, 2, 3, 4)

# rigged functions calling themselves are not opened/closed right
add2(add2(1, 2), add2(3, 4))

# recursive calls of rigged functions are not opened/closed right
rec_factorial(2)

works :

image

doesn't :

image

doesn't either:

image

I believe the mask might contain a variable ..STATE.. that would be a list, the first call of a rigged function would add an item to that list, and set up that it would be peeled off on exit (with withr::defer_parent as done atm). then wrap()ped functions would look at the last item.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions