Skip to content

Infinite recursion in as.data.table() #6878

@beckerbenj

Description

@beckerbenj

Using as.data.table.data.frame() on a data.frame which inherits from another class leads to an infinite recursion. This seems to have been introduced in #6865 and also came up in #6874. The issue is caused in line 218 in as.data.table.R:

if (!identical(class(x), "data.frame")) return(as.data.table(as.data.frame(x), keep.rownames=keep.rownames, key=key, ...))

# Minimal reproducible example (not executed as this breaks reprex)

df1 <- data.frame(var1 = 1:10)
class(df1) <- c("data.frame", "someClass")
out <- data.table::as.data.table(df1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions