RobinHankin / disordR

https://robinhankin.github.io/disordR/
1 stars 0 forks source link

replacement methods not returning an error #39

Closed RobinHankin closed 1 year ago

RobinHankin commented 1 year ago

If an extraction operation returns a dropped value, the replacement methods can incorrectly return a meaningless value:

> a <- disord(c(1,1,-1,-1))
> a
A disord object with hash bda785a4f305ab7cff0cd25e77c7f76e4cbb6bbb and elements
[1]  1  1 -1 -1
(in some order)
> a[a>0] <- 5:6
> a
A disord object with hash bda785a4f305ab7cff0cd25e77c7f76e4cbb6bbb and elements
[1]  5  6 -1 -1
(in some order)
> 

Above we see a[a>0] <- 5:6 returning a value, but the idiom should return an error.

This was causing problems in the freealg package:

https://github.com/RobinHankin/freealg/issues/31