Skip to content

infinite recursion when inheriting from same class #282

@tdhock

Description

@tdhock

hi, I made a mistake, accidentally specifying the class itself as inherit, which resulted in an infinite loop. I was surprised to see that is actually even allowed for the class definition:

> MyClass=R6::R6Class(inherit=MyClass)

I actually got no output (success) from the above line of code.
I would have expected/liked an error when running the above code, something like below:

> R6::R6Class(inherit=Undefined)$new()
Error in eval(inherit, parent_env, NULL) : object 'Undefined' not found

However I only got an error message later, shown below

> MyClass=R6::R6Class(inherit=MyClass)
> MyClass$new()
Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

It was easy how to fix this issue, but it would have been even more obvious/user friendly if the error happens earlier (on R6Class definition), would that be possible please?
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions