wahani / modules

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

`extend` with sourced module with `use` returns error #16

Closed krystian8207 closed 4 years ago

krystian8207 commented 4 years ago

Hi @wahani. Thank you for the great package!

I've found one issue while trying to use extend function with module sourced from the file.

Reproducible example:

# module.R
export("bar")
bar <- function() "bar"
foo <- function() "foo"

When sourcing the module with use and trying to extend it:

test_module <- use("module.R")
extend(
  test_module, {
  stopifnot(foo() == "foo") 
})

I get:

Error in parse(text = c("{", originalExpr, additionalExpr, "}")) : 
  <text>:3:41: unexpected '<'
2: structure(expression(export("bar"), bar <- function() "bar", 
3:     foo <- function() "foo"), srcfile = <
                                           ^

I'd be happy if you could take a closer look at it. Thank you.

wahani commented 4 years ago

@krystian8207 thanks for reporting this issue. It is a bug while parsing/deparsing the source code of modules. I have prepared a fix. You may install it with:

remotes::install_github("wahani/modules", "feature16")

Please report back if this resolves your issue.

krystian8207 commented 4 years ago

@wahani Thank you so much. The change fixes my issue.

wahani commented 4 years ago

Thanks for reporting back! It's now in master and with the next release on CRAN.

dokato commented 3 years ago

hey @wahani, thanks for creating this package. I encountered this error too, but I'm using it in a project where installation from github is a big no-go. Are you planning the new CRAN release any time soon?

wahani commented 3 years ago

@dokato kind of. I was hoping to close some of the other issues. But I am still waiting for feedback. I see what I can do and release it asap with the current bug fixes included.

wahani commented 3 years ago

@dokato on it's way to CRAN now.

dokato commented 3 years ago

That's great, thanks!