Skip to content

Double-quote non-syntactic names in combined importFrom() - #1924

Merged
hadley merged 1 commit into
mainfrom
fix-importfrom-nonsyntactic
Oct 2, 2026
Merged

hadley merged 1 commit into
mainfrom
fix-importfrom-nonsyntactic

Conversation

@hadley

@hadley hadley commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Fixes #1915.

roxygen2 8.x merges @importFrom tags into a single directive per package (to fix a loadNamespace() performance issue). But this exposed a base R bug in parseNamespaceFile(): it converts the import names with as.character() on a call object, which takes the first element verbatim but deparses the rest — and deparse adds backticks around non-syntactic names:

as.character(quote(f(`model<-`))[-1L])
#> [1] "model<-"        # backticks stripped

as.character(quote(f(x, `model<-`))[-1L])
#> [1] "x" "`model<-`"  # backticks kept!

We fix this by normalising all names to double quotes, which parse correctly in any position:

base:::parseNamespaceFile(...)$imports  # importFrom(rxode2, RxODE, "model<-")
#> [1] "RxODE"   "model<-"

Apart from tests, also verified end-to-end locally with a minimal package with the generated importFrom(rxode2,\n "model<-",\n RxODE\n) installs cleanly against the real rxode2.

roxygen2 8.x merges `@importFrom` tags into one directive per package, but a
base R bug in `parseNamespaceFile()` only strips backticks from the *first*
name in an `importFrom()` directive (`as.character()` on a call object takes
the head verbatim but deparses the rest). Backticked names like `` `model<-` ``
in position 2+ were recorded with literal backticks and failed installation
with "object '`model<-`' is not exported".

Normalise all import names to double quotes, which parse correctly in any
position, and dedupe equivalent quoting forms while at it.

Fixes #1915.
@hadley
hadley force-pushed the fix-importfrom-nonsyntactic branch from 04145b3 to 4abeb7c Compare October 2, 2026 12:53
@hadley
hadley merged commit 13b0c6b into main Oct 2, 2026
13 checks passed
@hadley
hadley deleted the fix-importfrom-nonsyntactic branch October 2, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

roxgyen2 re-exports are now broken for backtick quoted names

1 participant