Skip to content

Commit

Permalink
as.environment() argument name is x
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@87707 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
maechler committed Feb 7, 2025
1 parent b6e2688 commit 3578a3f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions doc/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@
\item \command{R CMD Rd2pdf} can now render the package manual from
a \option{--latex} installation also when the help contains figures.
\item The argument of \code{as.environment()} is named \code{x} now,
not \code{object}, as it was always documented and shown when
printing it; thanks to \I{Gael Millot}'s \PR{18849}.
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/envir.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
* Copyright (C) 1999--2024 The R Core Team.
* Copyright (C) 1999--2025 The R Core Team.
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -3302,7 +3302,7 @@ do_as_environment(SEXP call, SEXP op, SEXP args, SEXP rho)
{
SEXP arg = CAR(args), ans;
checkArity(op, args);
check1arg(args, call, "object");
check1arg(args, call, "x");
if(isEnvironment(arg))
return arg;
/* DispatchOrEval internal generic: as.environment */
Expand Down Expand Up @@ -3866,6 +3866,7 @@ attribute_hidden SEXP do_getRegNS(SEXP call, SEXP op, SEXP args, SEXP rho)
return R_NilValue; // -Wall
}

// .Internal(getNamespaceRegistry())
attribute_hidden SEXP do_getNSRegistry(SEXP call, SEXP op, SEXP args, SEXP rho)
{
checkArity(op, args);
Expand Down
6 changes: 6 additions & 0 deletions tests/reg-tests-1e.R
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,12 @@ options(op)# reverting
## in R < 4.4.z only *one* message .. "NA/Inf replaced by ...."


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



## keep at end
rbind(last = proc.time() - .pt,
Expand Down

0 comments on commit 3578a3f

Please sign in to comment.