Skip to content

setDT() fails in case of nested calls #6735

Description

@MichaelChirico

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>).

Activity

  1. added this to the 1.17.0 milestone on Jan 19, 2025
  2. rikivillalba commented on Jan 22, 2025

    @rikivillalba
    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"
  3. added a commit that references this issue on Jan 23, 2025
  4. MichaelChirico commented on Jan 23, 2025

    @MichaelChirico
    MemberAuthor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions