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

setDT() fails in case of nested calls #6735

Closed
MichaelChirico opened this issue Jan 19, 2025 · 2 comments · Fixed by #6755
Closed

setDT() fails in case of nested calls #6735

MichaelChirico opened this issue Jan 19, 2025 · 2 comments · Fixed by #6755
Milestone

Comments

@MichaelChirico
Copy link
Member

MichaelChirico commented Jan 19, 2025

The {marginaleffects} case in #6575 is pretty hard to tease apart, but I found this example that could be related where 1.16.4 and current master differ in behavior:

baz = function(x) setDT(x)
foo = function(x) {
  bar = function() baz(x)
  x = data.frame(a=1)
  bar()
  class(x)
}
foo()

## 1.16.4
# [1] "data.table" "data.frame"

## current master
# [1] "data.frame"

From debugging of {marginaleffects} thus far, I only found that, in contrast to #6701 and #6725, {marginaleffects} (in example(comparisons) where R CMD check is failing, at least) only calls simply setDT(<name>).

@MichaelChirico MichaelChirico added this to the 1.17.0 milestone Jan 19, 2025
@rikivillalba
Copy link
Contributor

I do not even need foo nor bar to reproduce in devel:

library(data.table)
baz = function(x) setDT(x)
x = data.frame(a=1)
baz(x)
class(x)
# [1] "data.frame"

@MichaelChirico
Copy link
Member Author

Nice, thanks! I added it to #6755 as a regression test

ben-schwen pushed a commit that referenced this issue Jan 27, 2025
* Revert change for setDT() to make a shallow copy

* convert #6735 examples to tests

* tweak
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.

2 participants