Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in NextMethod() : generic function not specified #298

Closed
JanMarvin opened this issue Feb 14, 2025 · 4 comments · Fixed by #299
Closed

Error in NextMethod() : generic function not specified #298

JanMarvin opened this issue Feb 14, 2025 · 4 comments · Fixed by #299

Comments

@JanMarvin
Copy link

JanMarvin commented Feb 14, 2025

After the update to R6 2.6.0 I'm seeing this error a lot in the Rstudio console. Using the example from here

Queue <- R6Class("Queue",
  public = list(
    initialize = function(...) {
      for (item in list(...)) {
        self$add(item)
      }
    },
    add = function(x) {
      private$queue <- c(private$queue, list(x))
      invisible(self)
    },
    remove = function() {
      if (private$length() == 0) return(NULL)
      # Can use private$queue for explicit access
      head <- private$queue[[1]]
      private$queue <- private$queue[-1]
      head
    }
  ),
  private = list(
    queue = list(),
    length = function() base::length(private$queue)
  )
)

q <- Queue$new(5, 6, "foo")

Now type the following and press any key. Each key creates a new Error in NextMethod() : generic function not specified

q$

Saw this in Rstudio on Windows R 4.1.2, but also on Rstudio (2024.12.0 Build 467) and R 4.4.2 with openxlsx2 (JanMarvin/openxlsx2#1268)

Is there any way to stop this?

@wch
Copy link
Member

wch commented Feb 14, 2025

Edit: I previously posted a message that said I wasn't able to reproduce it, but I had neglected to update R6 to 2.6.0.

I am able to reproduce this in RStudio. But the problem doesn't happen in R in the terminal.

@JanMarvin
Copy link
Author

Thanks!

@vladimirobucina
Copy link

@wch I'm not sure if this is related, but it is strange to me that it occurred recently and also with R6 version 2.6.0. So when I go back to version 2.5.1 autocompletion works, but with the newest version it stops.

Here some more info:

  • R version: 4.4.3
  • Positron version: 2024.12.0 (Universal) build 41
  • Operating System: macOS Sequoia 15.3.1

Btw, I'm using Air.

@wch
Copy link
Member

wch commented Mar 7, 2025

@vladimirobucina I think I'm able to reproduce the problem: with Positron and R6 2.6.1, tab-completion doesn't seem to work. Can you file a new issue for this?

Reproducible example:

library(R6)
AC <- R6Class("AC",
    public = list(
        x = 1
    )
)

a <- AC$new()

# Press <tab> below
a$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants