Open RLesur opened 5 years ago
In promise_map(), if the function .f returns NULL, the value of the fulfilled promise is incorrect. Here is a minimal reproducible example:
promise_map()
.f
NULL
library(promises) test_promise_map <- function(first_res, second_res) { f <- function(index) { switch(index, first_res, second_res) } promise_map(1:2, f) %...>% print() } test_promise_map("anything", "anything_else") #> [[1]] #> [1] "anything" #> #> [[2]] #> [1] "anything_else" test_promise_map(NULL, "anything_else") #> [[1]] #> NULL test_promise_map("anything", NULL) #> [[1]] #> [1] "anything"
My guess is the problem is located here: https://github.com/rstudio/promises/blob/852e9be0cd2c91aa72105ed0f2dacfd66d97d6f6/R/utils.R#L152 When this_value is NULL the corresponding element of the results list is removed.
this_value
results
In
promise_map()
, if the function.f
returnsNULL
, the value of the fulfilled promise is incorrect. Here is a minimal reproducible example:My guess is the problem is located here: https://github.com/rstudio/promises/blob/852e9be0cd2c91aa72105ed0f2dacfd66d97d6f6/R/utils.R#L152 When
this_value
isNULL
the corresponding element of theresults
list is removed.