Skip to content

Commit

Permalink
Fix NSE in shim_help(package = )
Browse files Browse the repository at this point in the history
Closes #266
  • Loading branch information
lionel- committed Jan 24, 2024
1 parent 4648ab4 commit 39dbb2b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# pkgload (development version)

* Fixed a bug in `shim_help()` where a complex `package = ` argument
evaluating to `NULL` would cause an error (#266).


# pkgload 1.3.4

* On load, pkgload now sets `PKGLOAD_PARENT_TEMPDIR` to the temporary
Expand Down
7 changes: 4 additions & 3 deletions R/dev-help.R
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,12 @@ shim_help <- function(topic, package = NULL, ...) {
package_name <- substitute(package)
if (is_symbol(package_name)) {
package_str <- as_string(package_name)
} else if (is_null(package_name)) {
package_str <- NULL
} else {
# Complex expression, just evaluate it (#266). The value is
# injected in `utils::help(package = )` below, causing it to be
# interpreted as is.
package_str <- package
package_name <- sym(package)
package_name <- package
}

use_dev <-
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-help.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ test_that("shim_help behaves the same as utils::help for nonexistent objects", {
expect_equal(length(shim_help("foofoo")), 0)
})

test_that("shim_help works with complex NULL `package = ` argument (#266)", {
expect_equal(
class(pkgload:::shim_help(list, package = (NULL))),
"help_files_with_topic"
)
})

test_that("shim_question behaves the same as utils::? for non-devtools-loaded packages", {
expect_identical(shim_question(lm)[1], utils::`?`(lm)[1])
Expand Down

0 comments on commit 39dbb2b

Please sign in to comment.