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

BUG: walkAST() may give Error: Cannot walk expression. Unknown object type 'list' #27

Closed
HenrikBengtsson opened this issue Jun 29, 2017 · 2 comments
Assignees
Labels
Milestone

Comments

@HenrikBengtsson
Copy link
Collaborator

In futureverse/future#156, it was reported that:

> y <- future::future_lapply(1L, function(a, b) typeof(b), b = list())
Error: Cannot walk expression. Unknown object type 'list'

with traceback:

1: future::future_lapply(1, function(a, b) typeof(b), b = list())
2: getGlobalsAndPackages(expr, envir = envir, tweak = tweakExpression, globals =
3: globalsOf(expr, envir = envir, substitute = FALSE, tweak = tweak, dotdotdot =
4: findGlobals(expr, envir = envir, ..., method = method, tweak = tweak, substit
5: tweak(expr)
6: walkAST(expr, call = tweakFutureAssignmentCall)
7: walkAST(expr[[cc]], atomic = atomic, name = name, call = call, pairlist = pai
8: stop("Cannot walk expression. Unknown object type ", sQuote(typeof(expr)), ca

In the above call, expr is effectively

> expr <- substitute(FUN(b = B), list(B = list()))
> str(expr)
 language FUN(b = list())

and walking the AST on that expression gives the error:

> globals::walkAST(expr)
Error: Cannot walk expression. Unknown object type 'list'

The error is triggered on the second component of expr, which is of type list:

> str(expr[[2]])
 list()
> typeof(expr[[2]])
[1] "list"

Note, this is not the same as:

> expr <- substitute(FUN(b = list()))
> str(expr)
 language FUN(b = list())

because there we have:

> str(expr[[2]])
 language list()
> typeof(expr[[2]])
[1] "language"

The current walkAST() code assumes the latter, but not the former.

/cc @ck37

@HenrikBengtsson HenrikBengtsson added this to the Next release milestone Jun 29, 2017
@HenrikBengtsson HenrikBengtsson self-assigned this Jun 29, 2017
@HenrikBengtsson
Copy link
Collaborator Author

Another problematic type is expression;

> y <- future::future_lapply(1L, function(a, b) typeof(b), b = expression())
Error: Cannot walk expression. Unknown object type 'expression'

HenrikBengtsson added a commit that referenced this issue Jun 29, 2017
…wn object type 'list'" and same for 'expression' (Issue #27)
HenrikBengtsson added a commit that referenced this issue Jun 29, 2017
…ning"

will cause walkAST() to only produce a warning (instead of an error) if there
is "unknown type" is detected.  This allows users to (try to) keep working
in case there a data type is discovered that was not accounted for (Issue #27).
@HenrikBengtsson
Copy link
Collaborator Author

This should have now been fixed in the develop branch;

remotes::install_github("HenrikBengtsson/globals@develop")

I've added package unit tests for it. I'm currently running reverse-dependency package tests (for everything on CRAN and Bioconductor), which will take some time. I'll reopen if I find something unexpected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant