Skip to content

Commit 996f83b

Browse files
committed
Further refinement following rebase
1 parent bb52f85 commit 996f83b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

inst/include/Rcpp/Function.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,20 @@ namespace Rcpp{
7070
}
7171

7272
Function_Impl(const std::string& name, const std::string& ns) {
73-
#if R_VERSION < R_Version(4,6,0)
73+
#if R_VERSION < R_Version(4,5,0)
74+
// before R 4.5.0 we would use Rf_findVarInFrame
7475
Shield<SEXP> env(Rf_findVarInFrame(R_NamespaceRegistry, Rf_install(ns.c_str())));
7576
if (env == R_UnboundValue)
76-
Shield<SEXP> env(R_getRegisteredNamespace(ns.c_str()));
77+
stop("there is no namespace called \"%s\"", ns);
78+
#elif R_VERSION < R_Version(4,6,0) || R_SVN_REVISION < 89746
79+
// during R 4.5.* and before final R 4.6.0 we could use R_getVarEx
80+
// along with R_NamespaceRegistry but avoid R_UnboundValue
81+
Shield<SEXP> env(R_getVarEx(Rf_install(ns.c_str()), R_NamespaceRegistry, FALSE, R_NilValue));
7782
if (env == R_NilValue)
7883
stop("there is no namespace called \"%s\"", ns);
7984
#else
80-
Shield<SEXP> env(R_getVarEx(Rf_install(ns.c_str()), R_NamespaceRegistry, FALSE, R_NilValue));
85+
// late R 4.6.0 development got us R_getRegisteredNamespace
86+
Shield<SEXP> env(R_getRegisteredNamespace(ns.c_str()));
8187
if (env == R_NilValue)
8288
stop("there is no namespace called \"%s\"", ns);
8389
#endif

0 commit comments

Comments
 (0)