wahani / modules

Modules in R
https://cran.r-project.org/package=modules
Other
81 stars 3 forks source link

crash when module contains special character function #45

Closed klin333 closed 1 year ago

klin333 commented 1 year ago

Hi,

Creating a module with special character functions would crash... Not sure what can be done about this.

modules::module({
  `[` <- function(..., drop = FALSE) .Primitive("[")(..., drop = drop)
})
Error: unable to resolve export: [
failed with
Error in parse(text = element): <text>:1:1: unexpected '['
1: [
    ^
klin333 commented 1 year ago

Hi, even with fix of #44, this problem still persisted.

However, a word around is to force no export of the special character function, which in my case I probably don't want exported anyway.

modules::export("^[a-zA-Z0-9_\\.]+")

`[` <- function(..., drop = FALSE) .Primitive("[")(..., drop = drop)

foo <- function() {
  array(1, dim = c(1, 1))[1, ] # check no drop by default
}
wahani commented 1 year ago

Hi. Thanks for bringing this up.

To understand the issue better: you are using a function name like [ inside the module which you do not wish to export, correct?

In any case, we should not see this error.

wahani commented 1 year ago

Can you pls check a potential fix with:

remotes::install_github("wahani/modules", ref = "fix/export-of-single-punct-name")
klin333 commented 1 year ago

looks good thanks

wahani commented 1 year ago

@klin333 fyi: On it's way to CRAN