From bb52f85e06341e7969c95044ae17c76594c9ddca Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Thu, 2 Apr 2026 19:28:41 -0500 Subject: [PATCH 1/2] Further R-devel driven refinement for function-in-namespace lookup --- ChangeLog | 5 +++++ inst/include/Rcpp/Function.h | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1d7e8be83..f74e3af0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2026-04-02 Dirk Eddelbuettel + + * inst/include/Rcpp/Function.h: Further refinement for 4.6.0 to not + require R_NamespaceRegistry, using R_getRegisteredNamespace() instead + 2026-04-01 Mattias Ellert * inst/discovery/cxx0x.R: Set execute permissions for script diff --git a/inst/include/Rcpp/Function.h b/inst/include/Rcpp/Function.h index 58f12d7e9..a48d9c083 100644 --- a/inst/include/Rcpp/Function.h +++ b/inst/include/Rcpp/Function.h @@ -70,9 +70,11 @@ namespace Rcpp{ } Function_Impl(const std::string& name, const std::string& ns) { -#if R_VERSION < R_Version(4,5,0) +#if R_VERSION < R_Version(4,6,0) Shield env(Rf_findVarInFrame(R_NamespaceRegistry, Rf_install(ns.c_str()))); if (env == R_UnboundValue) + Shield env(R_getRegisteredNamespace(ns.c_str())); + if (env == R_NilValue) stop("there is no namespace called \"%s\"", ns); #else Shield env(R_getVarEx(Rf_install(ns.c_str()), R_NamespaceRegistry, FALSE, R_NilValue)); From 996f83b9b031220721f91022fc7cb14bc3547458 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Thu, 2 Apr 2026 20:15:11 -0500 Subject: [PATCH 2/2] Further refinement following rebase --- inst/include/Rcpp/Function.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/inst/include/Rcpp/Function.h b/inst/include/Rcpp/Function.h index a48d9c083..c98777bd3 100644 --- a/inst/include/Rcpp/Function.h +++ b/inst/include/Rcpp/Function.h @@ -70,14 +70,20 @@ namespace Rcpp{ } Function_Impl(const std::string& name, const std::string& ns) { -#if R_VERSION < R_Version(4,6,0) +#if R_VERSION < R_Version(4,5,0) + // before R 4.5.0 we would use Rf_findVarInFrame Shield env(Rf_findVarInFrame(R_NamespaceRegistry, Rf_install(ns.c_str()))); if (env == R_UnboundValue) - Shield env(R_getRegisteredNamespace(ns.c_str())); + stop("there is no namespace called \"%s\"", ns); +#elif R_VERSION < R_Version(4,6,0) || R_SVN_REVISION < 89746 + // during R 4.5.* and before final R 4.6.0 we could use R_getVarEx + // along with R_NamespaceRegistry but avoid R_UnboundValue + Shield env(R_getVarEx(Rf_install(ns.c_str()), R_NamespaceRegistry, FALSE, R_NilValue)); if (env == R_NilValue) stop("there is no namespace called \"%s\"", ns); #else - Shield env(R_getVarEx(Rf_install(ns.c_str()), R_NamespaceRegistry, FALSE, R_NilValue)); + // late R 4.6.0 development got us R_getRegisteredNamespace + Shield env(R_getRegisteredNamespace(ns.c_str())); if (env == R_NilValue) stop("there is no namespace called \"%s\"", ns); #endif