r-lib / R6

Encapsulated object-oriented programming for R
https://R6.r-lib.org
Other
403 stars 56 forks source link

$debug("initialize") enters recursive debugging mode #224

Closed duccioa closed 3 years ago

duccioa commented 3 years ago

When I try to debug a class with MyR6Class$debug("initialize") or with browser() inside the code, the debugger enters a sort of recursive mode where it steps into every single function that is called. So for example, if the $initialize() function contains a line with is.character(x), the debugger would debug also the function is.character. This behaviour is a bit erratic and so far I haven't been able to understand when this issues comes up and I am not able to provide a reproducible example. I did some research but I could not find anything relevant,so I am posting here in case someone has bumped into the same issue. I am working with RStudio Version 1.4.999. This is my system info:

sysname
"Darwin"
release
"20.2.0"
version
"DarwinKernelVersion20.2.0:WedDec220:39:59PST2020;root:xnu-7195.60.75~1/RELEASE_X86_64"
nodename
"Duccios-MacBook-Pro.local"
machine
"x86_64"
login
"root"
user
"duccioa"
effective_user
"duccioa"

A bit more information about the context. I have a package A with R6 classes and a second package B with classes that inherit from classes in A. This is the situation when the issues arises most often, I think.

Thank you

duccioa commented 3 years ago

With a bit of extra testing I eventually realised that this has nothing to do with R6 and it is not a bug. It's a feature of browser(), that lets you uses some commands at the browser prompt. One of these is s, that by chance is also a variable that I am using a lot...