tidyverse / purrr

A functional programming toolkit for R

Home Page:https://purrr.tidyverse.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compose hits infinite recursion with custom "invisibly" adverb

byronvickers opened this issue · comments

When implementing a custom adverb to make return values invisible, composition of this adverb is somehow causing an infinite recursion.

library(purrr)

invisibly = function(.f){
  function(...){
    invisible(.f(...))
  }
}

compose(invisibly, quietly)(sum)(1:3)
#> Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
#> Error during wrapup: evaluation nested too deeply: infinite recursion / options(expressions=)?
#> Error: no more error handlers available (recursive errors?); invoking 'abort' restart

However, invisibly(quietly(sum))(1:3) performs as expected (i.e. invisibly returns the output of quietly(sum)(1:3)).

This seems possibly related to #828 but the end result there is unexpected output rather than an infinite recursion. Still, I imagine this issue would also be resolved by #651; is that work still planned or has it been shelved?

Apologies if I've missed something in the docs or issues that would explain why I'm getting this behaviour!