-
Notifications
You must be signed in to change notification settings - Fork 161
Closed
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behavior
Description
Sorry if this appears a little obscure, it's causing me some difficulty.
I found this issue after you posted a review for hedgehog (ta!). Using the pipe I was having infinite recursion due to the environments being brought into functions incorrectly.
Here's a quick bug showing something similar
compose <- function(f, g) { function(x) g(f(x)) }
plus1 <- function(x) x + 1
compose(plus1, plus1)(5)
# [1] 7
plus2 <- plus1 %>% compose(plus1)
plus2(5)
# Error in g(f(x)) : could not find function "f"
plus2
# function(x) g(f(x))
# <environment: 0x7f977ecd1ea8>
as.list(environment(plus2))
# $f
# $f$value
# function (x)
# g(f(x))
# <environment: 0x7f977ecd1ea8>
#
# $f$visible
# [1] TRUE
# $g
# function (x)
# x + 1
See above that f$value
refers to g(f(x))
, when it should be function(x) x + 1
.
Metadata
Metadata
Assignees
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behavior