Skip to content

Commit

Permalink
Don't create a constructor called "function" (#280)
Browse files Browse the repository at this point in the history
Fixes #249. Fixes #279.
  • Loading branch information
hadley authored Feb 19, 2023
1 parent 4d5380b commit 249b884
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions R/base.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
new_base_class <- function(name) {
new_base_class <- function(name, constructor_name = name) {
force(name)

constructor <- function(.data = class_missing) {
Expand All @@ -16,6 +16,7 @@ new_base_class <- function(name) {

out <- list(
class = name,
constructor_name = constructor_name,
constructor = constructor,
validator = validator
)
Expand Down Expand Up @@ -143,7 +144,7 @@ class_expression <- new_base_class("expression")
#' @rdname base_classes
#' @format NULL
#' @order 1
class_function <- new_base_class("function")
class_function <- new_base_class("function", "fun")

#' @export
#' @rdname base_classes
Expand Down
2 changes: 1 addition & 1 deletion R/constructor.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ new_constructor <- function(parent, properties) {
parent_fun <- parent
args <- missing_args(union(arg_info$parent, arg_info$self))
} else if (is_base_class(parent)) {
parent_name <- parent$class
parent_name <- parent$constructor_name
parent_fun <- parent$constructor
args <- missing_args(union(arg_info$parent, arg_info$self))
} else if (is_S3_class(parent)) {
Expand Down

0 comments on commit 249b884

Please sign in to comment.