Thanks for the report.  This is now fixed in R-devel and R-patched
by increasing NAMED on the RHS value to 2 when it is not 0.

Best,

luke

On Tue, 8 Jan 2013, Justin Talbot wrote:

In R version 2.15.2 (2012-10-26) i386-apple-darwin9.8.0/i386 (32-bit) I get
the following:

a <- list(1)
(a[[1]] <- a)
[[1]]
[[1]][[1]]
[1] 1

but

a <- list(1)
b <- a
(a[[1]] <- a)
[[1]]
[1] 1

And similarly:

a <- list(x=1)
(a$x <- a)
$x
$x$x
[1] 1

but

a <- list(x=1)
b <- a
(a$x <- a)
$x
[1] 1

In both cases the result of the first sequence is wrong. It's returning the
updated `a` rather than the RHS of the assignment. The second sequence in
both cases is correct; the assignment to `b` increments the NAMED value
causing the necessary copy to be made so the RHS is returned from the
assignment.

Would it be sufficient to add a check to do_subassign2_dflt
and do_subassign3_dflt that creates a duplicate of the LHS if the LHS & RHS
are the same object?

Justin

        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


--
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
   Actuarial Science
241 Schaeffer Hall                  email:   luke-tier...@uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to