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

R session aborts when a generics fun overwrites a supplied argument #254

Closed
KaiAragaki opened this issue Oct 11, 2022 · 4 comments · Fixed by #289
Closed

R session aborts when a generics fun overwrites a supplied argument #254

KaiAragaki opened this issue Oct 11, 2022 · 4 comments · Fixed by #289
Labels
bug an unexpected problem or unintended behavior

Comments

@KaiAragaki
Copy link

Apologies if this should be directed to the RStudio repo.

Reprex:

library(R7)

my_generic <- new_generic("my_generic", "x", function(x) {
  x <- x
  R7_dispatch()
})

my_method <- method(my_generic, class_character) <- function(x) {
  x
}

my_generic("x")

This is fine though:

my_generic <- new_generic("my_generic", "x", function(x) {
  ex <- x
  R7_dispatch()
})

my_generic("x")

RStudio version: 2022.07.2+576 (2022.07.2+576)
OS: macOS 12.6

@hadley
Copy link
Member

hadley commented Oct 12, 2022

What do you mean by crashes?

@KaiAragaki
Copy link
Author

Sorry - not RStudio, but rather the R Session. I'll change the title. See image for details.

Reproduced on Linux (Mint 20.3 Cinnamon), which screams before it dies (see console in background)

image

@KaiAragaki KaiAragaki changed the title RStudio crashes when a generics fun overwrites a supplied argument R session aborts when a generics fun overwrites a supplied argument Oct 13, 2022
@hadley hadley added the bug an unexpected problem or unintended behavior label Apr 10, 2023
@hadley
Copy link
Member

hadley commented Apr 14, 2023

Updated reprex:

library(S7)

my_generic <- new_generic("my_generic", "x", function(x) {
  x <- x
  S7_dispatch()
})

method(my_generic, class_character) <- function(x) {
  x
}

my_generic("x")

I also see the crash

@hadley
Copy link
Member

hadley commented Apr 14, 2023

Error is coming from https://github.com/RConsortium/OOP-WG/blob/abstract-parent-readonly-property/src/method-dispatch.c#L133, presumably because this isn't an unevaluated promise.

hadley added a commit that referenced this issue Apr 14, 2023
To allow dispatch on evaluated arguments. Fixed #254
hadley added a commit that referenced this issue Apr 18, 2023
To allow dispatch on evaluated arguments. Fixed #254
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants