Skip to content

Commit c716904

Browse files
committed
add error
1 parent af6f4e8 commit c716904

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

R/ggproto.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,14 @@ fetch_ggproto <- function(x, name) {
131131
if (is.null(super)) {
132132
# no super class
133133
} else if (is.function(super)) {
134-
res <- fetch_ggproto(super(), name)
134+
parent <- super()
135+
if (!identical(parent, x)) {
136+
# happy path
137+
return(fetch_ggproto(parent, name))
138+
}
139+
cli::cli_abort(
140+
"{.cls {class(x)[1]}} cannot have a circular definition."
141+
)
135142
} else {
136143
cli::cli_abort(c(
137144
"{class(x)[[1]]} was built with an incompatible version of ggproto.",

0 commit comments

Comments
 (0)