Skip to content

Commit e0691ad

Browse files
committed
NEWS bullet about condition
1 parent c311daf commit e0691ad

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# dplyr (development version)
22

3+
* `if_else()` no longer allows `condition` to be a logical array. It must be a logical vector with no `dim` attribute (#7723).
4+
35
* `if_else()` has gotten significantly faster and uses much less memory due to a rewrite in C via `vctrs::vec_if_else()` (#7723).
46

57
* Passing `size` to `if_else()` is now deprecated. The output size is always taken from the `condition` (#7722).

tests/testthat/_snaps/if-else.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
Error in `if_else()`:
2323
! `condition` must be a logical vector, not an integer vector.
2424

25+
# `condition` can't be an array (#7723)
26+
27+
Code
28+
if_else(array(TRUE), 1, 2)
29+
Condition
30+
Error in `if_else()`:
31+
! `condition` must be a logical vector, not a logical vector.
32+
2533
# `true`, `false`, and `missing` must recycle to the size of `condition`
2634

2735
Code

tests/testthat/test-if-else.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ test_that("`condition` must be logical (and isn't cast to logical!)", {
7474
})
7575
})
7676

77+
test_that("`condition` can't be an array (#7723)", {
78+
expect_snapshot(error = TRUE, {
79+
# TODO: Error message will improve with
80+
# https://github.com/r-lib/rlang/pull/1832
81+
if_else(array(TRUE), 1, 2)
82+
})
83+
})
84+
7785
test_that("`true`, `false`, and `missing` must recycle to the size of `condition`", {
7886
x <- 1:3
7987
bad <- 1:2

0 commit comments

Comments
 (0)