`address(x)` fails when x is the missing argument
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
Research direction
Reproduce the failure with the supplied R examples for address(x), including the missing argument case, then trace the address implementation through the Caddress entry point. Compare the proposed maybe_missing workaround and verify that ordinary and missing arguments return the expected addresses, including the function-call example.
Written by the indexing model from the issue text.
Description
The code
library(data.table)
x <- quote(list(x=))[[2]] # extract the missing argument
missing(x) # TRUE
address(x) # Error in eval(substitute(x), parent.frame()) :
# argument "a" is missing, with no default
{function(x) address(x) }() # same error
will fail when x is the missing argument. I think it is a bug since x is a legitimate variable.
This is a situation similar to #1521 of rlang.
So i propose to apply the same workaround here (see maybe_missing of rlang for case.)
#PROPOSED SOLUTION:
address2 <- function (x) {
maybe_missing <- function (x, default = quote(list(x=))[[2]]) {
if (missing(x)) default else x
}
.Call("Caddress", eval(substitute(maybe_missing(x)), parent.frame()), PACKAGE= "data_table")
}
# TEST:
x <- quote(list(x=))[[2]]
y <- "something"
address2(x)
address2(y)
stopifnot(address2(y) == address(y)) #OK
stopifnot(paste0("0x",address2(x)) == rlang::obj_address(x)) #OK
stopifnot(paste0("0x",address2(y)) == rlang::obj_address(y)) #OK
{function(x) address2(x)}() # OK
Hope may be of help.
Tks.
- Dominant language
- R
- Stars
- 3.9k
- Forks
- 1.1k
- Avg merge
- 14h 4m
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Rdatatable/data.table
-
as.data.table() recurses without end on a survival::Surv object (or any data.frame carrying one) Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Rdatatable/data.table#7887 ·
-
consistency tests
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#7853 · 3 comments ·
-
internals
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#6938 · 1 comment ·
-
encoding fread
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#5179 · 8 comments ·
-
documentation programming
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#3199 · 3 comments ·
All issues in Rdatatable/data.table
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
r-lib/pkgdepends#485 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
beginners blocker
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enviPathR OpenBuild Error Build OK Build Warning policies-accepted pre-review precheck-passed
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Bioconductor/BiocContributions#207 · 6 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
datacarpentry/semester-biology#1255 ·