Skip to content

Commit 3578a3f

Browse files
author
maechler
committed
as.environment() argument name is x
git-svn-id: https://svn.r-project.org/R/trunk@87707 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent b6e2688 commit 3578a3f

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

doc/NEWS.Rd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,10 @@
550550
551551
\item \command{R CMD Rd2pdf} can now render the package manual from
552552
a \option{--latex} installation also when the help contains figures.
553+
554+
\item The argument of \code{as.environment()} is named \code{x} now,
555+
not \code{object}, as it was always documented and shown when
556+
printing it; thanks to \I{Gael Millot}'s \PR{18849}.
553557
}
554558
}
555559
}

src/main/envir.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* R : A Computer Language for Statistical Data Analysis
3-
* Copyright (C) 1999--2024 The R Core Team.
3+
* Copyright (C) 1999--2025 The R Core Team.
44
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
55
*
66
* This program is free software; you can redistribute it and/or modify
@@ -3302,7 +3302,7 @@ do_as_environment(SEXP call, SEXP op, SEXP args, SEXP rho)
33023302
{
33033303
SEXP arg = CAR(args), ans;
33043304
checkArity(op, args);
3305-
check1arg(args, call, "object");
3305+
check1arg(args, call, "x");
33063306
if(isEnvironment(arg))
33073307
return arg;
33083308
/* DispatchOrEval internal generic: as.environment */
@@ -3866,6 +3866,7 @@ attribute_hidden SEXP do_getRegNS(SEXP call, SEXP op, SEXP args, SEXP rho)
38663866
return R_NilValue; // -Wall
38673867
}
38683868

3869+
// .Internal(getNamespaceRegistry())
38693870
attribute_hidden SEXP do_getNSRegistry(SEXP call, SEXP op, SEXP args, SEXP rho)
38703871
{
38713872
checkArity(op, args);

tests/reg-tests-1e.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,6 +1833,12 @@ options(op)# reverting
18331833
## in R < 4.4.z only *one* message .. "NA/Inf replaced by ...."
18341834

18351835

1836+
## as.environment(x = .) should work
1837+
ee <- as.environment(x = list(a = 1, bb = 2))
1838+
stopifnot(is.environment(ee), length(ee) == 2L)
1839+
## instead, for R <= 4.4.z, no name or as.environment(object = .) was needed
1840+
1841+
18361842

18371843
## keep at end
18381844
rbind(last = proc.time() - .pt,

0 commit comments

Comments
 (0)