Skip to content

Commit

Permalink
call prop_is_read_only() as appropriate; fixes #421
Browse files Browse the repository at this point in the history
  • Loading branch information
lawremi committed Aug 24, 2024
1 parent 2812f55 commit 86d2a4a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/constructor.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ constructor_args <- function(parent, properties = list()) {

self_args <- names2(properties)
# Remove dynamic arguments
self_args <- self_args[vlapply(properties, function(x) is.null(x$getter))]
self_args <- self_args[vlapply(properties, Negate(prop_is_read_only))]
if (is_class(parent) && !parent@abstract) {
# Remove any parent properties; can't use parent_args() since the constructor
# might automatically set some properties.
Expand Down
2 changes: 1 addition & 1 deletion R/property.R
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ prop_obj <- function(object, name) {
stop(prop_error_unknown(object, name), call. = FALSE)
}

if (!is.null(prop$getter) && is.null(prop$setter)) {
if (prop_is_read_only(prop)) {
msg <- sprintf("Can't set read-only property %s@%s", obj_desc(object), name)
stop(msg, call. = FALSE)
}
Expand Down

0 comments on commit 86d2a4a

Please sign in to comment.