Repository navigation
Fix params.2.fname(): wrong names + missing export - #50
Conversation
Two bugs, found together while investigating why fixing parFlags()'s
R CMD check error (a separate PR) unmasked a new "checking examples"
ERROR in params.2.fname():
1. Broken logic: nmz <- as.character(substitute(list(...))[-1]) does
NOT recover the argument names. as.character() on a substituted call
deparses each element's VALUE, not its name. Verified directly:
for params.2.fname(aa = 1, cc = 2), this produced nmz = c("1", "2")
(the values, stringified) instead of c("aa", "cc") (the names), so
the function's own documented example, params.2.fname(aa = 1, cc =
2, d = NULL, sep = ".", collapse = "_"), returned "1.1_2.2" instead
of the documented "aa.1_cc.2" - every parameter name in the output
was silently replaced by that parameter's own value.
Fixed by using `names(x)` (x <- list(...) is already computed on the
line above) instead of the substitute/deparse trick.
2. Missing @export: despite having a complete roxygen block (title,
description, params, a worked example) matching every other exported
function's style, and already having a generated man/params.2.fname.Rd,
the function itself was never added to NAMESPACE. Its own example
couldn't even run under R CMD check ("could not find function
params.2.fname"), which is how bug 1 stayed unnoticed - the function
was never reachable by any external caller to begin with. Added @export.
Version bumped 1.2.1 -> 1.2.2 in Development/config.R and DESCRIPTION.
Validation: manually confirmed params.2.fname(aa = 1, cc = 2, d = NULL,
sep = ".", collapse = "_") now returns "aa.1_cc.2" as documented. R CMD
check's "checking examples" ERROR that was previously raised by this
function's own broken example is gone (NAMESPACE now correctly exports
it: export(params.2.fname), man/params.2.fname.Rd was already accurate
and needed no changes). The existing testthat suite still passes 7/7.
Remaining R CMD check findings (parFlags example error - fixed in
another PR in this batch, %!in% Rd name warning, sandbox locale
warning, and doc issues fixed in other independent PRs in this batch)
are pre-existing/environment-inherent and out of scope here.
Are we sure that this is actually what the intention of the function was? If it wasn't exported anyway, then it means that ProLdysfunction was not used at all. Can you validate across my packages that this function is even used? Because if not, maybe this is an outdated version and should just be removed. Please specifically go through the R subdirectory of my 5 most used repositories and check if they actually use this function. Also check if this package even uses this function. The connectome repository should be checked the most carefully. |
Co-authored-by: vertesy <5101911+vertesy@users.noreply.github.com>
Resolved in
Given that, I removed the stale unexported |
|
Copilot seems to be misguided In its comments above. params.2.fname() Should not be removed from the code base. It is used in one of my packages. |
|
Claude finished @vertesy's task in 4m 13s —— View job Done —
|
An earlier merge on this PR branch removed params.2.fname() entirely under the assumption it was dead code, but it is used in a downstream package. Restore the function together with the original bug fix (names(x) instead of the broken substitute/deparse trick) and its @export tag, man page, and doc/dependency-graph references. Co-authored-by: Abel Vertesy <5101911+vertesy@users.noreply.github.com>
How this was found
While fixing
parFlags()'s R CMD check error in a sibling PR in this batch, fixing it unmasked a new "checking examples" ERROR — R CMD check runs examples in file order and had been stopping atparFlags()before ever reaching this one.The bugs
1. Broken logic:
nmz <- as.character(substitute(list(...))[-1])does not recover the argument names.as.character()on a substituted call deparses each element's value, not its name. Verified directly: forparams.2.fname(aa = 1, cc = 2), this producednmz = c("1", "2")(the values, stringified) instead ofc("aa", "cc")(the names) — so the function's own documented example,params.2.fname(aa = 1, cc = 2, d = NULL, sep = ".", collapse = "_"), returned"1.1_2.2"instead of the documented"aa.1_cc.2". Every parameter name in the output was silently replaced by that parameter's own value.Fixed by using
names(x)(x <- list(...)is already computed on the line above) instead of the substitute/deparse trick.2. Missing
@export: despite having a complete roxygen block (title, description, params, a worked example) matching every other exported function's style, and already having a generatedman/params.2.fname.Rd, the function itself was never added to NAMESPACE. Its own example couldn't even run under R CMD check ("could not find functionparams.2.fname"), which is how bug 1 stayed unnoticed — the function was never reachable by any external caller to begin with. Added@export.Version bumped 1.2.1 → 1.2.2 in
Development/config.RandDESCRIPTION.Validation
Manually confirmed
params.2.fname(aa = 1, cc = 2, d = NULL, sep = ".", collapse = "_")now returns"aa.1_cc.2"as documented. R CMD check's "checking examples" ERROR previously raised by this function's own broken example is gone (NAMESPACE now correctly exports it;man/params.2.fname.Rdwas already accurate and needed no changes). The existingtestthatsuite still passes 7/7. Remaining R CMD check findings (parFlagsexample error — fixed in another PR in this batch,%!in%Rd-name warning, sandbox locale warning, and doc issues fixed in other independent PRs in this batch) are pre-existing/environment-inherent and out of scope here.Generated by Claude Code