ripley@stats.ox.ac.uk
2004-Nov-01 19:50 UTC
[Rd] (PR#7326)(inappropriate) manipulation of expression objects
On 29 Oct 2004, Peter Dalgaard wrote:> deepayan@stat.wisc.edu writes: > > > > foo <- expression(alpha, beta, gamma) > > > foo[2] > > expression(beta) > > > foo[2] <- NA > > > foo ## or str(foo) > > Segmentation fault > > > > (Same behaviour in R 1.9.1) > > > > 'foo[[2]] <- NA' works fine, though. > > Right. The NA is not important; foo[2] <- 1 crashes R just as > effectively. We should likely either give an error or demote [ to [[. > The latter is what happens with lists, and expressions are basically > just list of call objects (or names or constants). To wit: > > > x <- list(1,2,3) > > x[2] <- 1 > > x > [[1]] > [1] 1 > > [[2]] > [1] 1 > > [[3]] > [1] 3That's not the issue: VectorAssign has identical code for the vector list and expression cases. The issue is in SubassignTypeFix which says case 2010: /* expression <- logical */ /* Note : No coercion is needed here. */ /* We just insert the RHS into the LHS. */ /* FIXME: is this true or should it be just like the "vector" case? */ and at level=1 the FIXME is correct. Brian -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Seemingly Similar Threads
- (inappropriate) manipulation of expression objects causes segfault (PR#7326)
- Intermittent crashes with inset `[<-` command
- (PR#7309) misuse of R-bugs (was inappropriate definition
- Intermittent crashes with inset `[<-` command
- Bug in out-of-bounds assignment of list object to expression() vector