You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While trying to get something to work, I got to this minimal example, which resulted in an error that sounded like something in the S7 internals broke. Maybe I did someting obviously wrong, but I figured I'd file an issue just in case:
Error: <TestClass> object is invalid:
- Underlying data is corrupt
4.
stop(msg, call. = FALSE)
3.
function (object, recursive = TRUE, properties = TRUE)
{
check_is_S7(object)
if (!is.null(attr(object, ".should_validate"))) { ...
2.
`prop<-`(`*tmp*`, "x", value = 10)
1.
TestClass(x = 10)
Minimal Example:
TestClass <- S7::new_class(
"TestClass",
properties = list(
x = S7::new_property(default = NULL, validator = function(value) {
if (!is.null(value) && !is.numeric(value)) {
"@x must be numeric"
}
})
),
constructor = function(x = NULL) {
obj <- new_object(.parent = TestClass)
if (!is.null(x)) {
prop(obj, "x") <- x
}
obj
}
)
test_obj <- TestClass(x = 10)
The text was updated successfully, but these errors were encountered:
Hmmmm, the problem is that you're trying to work with the object before it's finished construction. I'm not sure if we could make a better error message here, but it would be nice if possible.
I suppose that would be a more informative error message :) It sounds a lot less like something internal is broken.
In case you're interested how I ended up here: This started with me trying to use (...) in the constructor which didn't work as do.call can't call new_object and I don't know another way of of calling a function with a list of unknown arguments.
Then I figured I'd just NULL all the properties that haven't been passed, as is.null felt clearer than if(length>0) for all the numeric()'s it created for empty properties instead. Which I didn't get to work the way I wanted and ultimately ended up as this example while trying to figure out what I was doing wrong.
While trying to get something to work, I got to this minimal example, which resulted in an error that sounded like something in the S7 internals broke. Maybe I did someting obviously wrong, but I figured I'd file an issue just in case:
Minimal Example:
The text was updated successfully, but these errors were encountered: