Skip to content

Commit

Permalink
Add NULL compat to expr_label() (#1656)
Browse files Browse the repository at this point in the history
Co-authored-by: Zelos Zhu <[email protected]>
Closes #1655.
  • Loading branch information
zdz2101 authored Oct 5, 2023
1 parent c55f602 commit 2a831ef
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

* `obj_type_friendly()` now only displays the first class of S3 objects (#1622).

* `expr_label()` now has back-compatility with respect to changes made by R version 4.4 and `is.atomic(NULL)` (#1655)

# rlang 1.1.1

* `englue()` now allows omitting `{{`. This is to make it easier to
Expand Down
2 changes: 1 addition & 1 deletion R/expr.R
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ is_symbolic <- function(x) {
expr_label <- function(expr) {
if (is.character(expr)) {
encodeString(expr, quote = '"')
} else if (is.atomic(expr)) {
} else if (is.null(expr) || is.atomic(expr)) {
format(expr)
} else if (is.name(expr)) {
paste0("`", as.character(expr), "`")
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-expr.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ test_that("expr_label() truncates long calls", {
expect_identical(expr_label(long_call), "`foo(...)`")
})

test_that("expr_label() NULL values come out as expected", {
expect_identical(expr_label(NULL), "NULL")
})

# expr_name() --------------------------------------------------------

Expand Down

0 comments on commit 2a831ef

Please sign in to comment.