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

Debugging difficulty with incorrect code #1371

Closed
6 tasks done
billdenney opened this issue Jul 2, 2021 · 2 comments
Closed
6 tasks done

Debugging difficulty with incorrect code #1371

billdenney opened this issue Jul 2, 2021 · 2 comments

Comments

@billdenney
Copy link
Contributor

Prework

  • Read and agree to the code of conduct and contributing guidelines.
  • If there is already a relevant issue, whether open or closed, comment on the existing thread instead of posting a new issue.
  • For any problem you identify, post a minimal reproducible example so the maintainer can troubleshoot. A reproducible example is:
    • Runnable: post enough R code and data so any onlooker can create the error on their own computer.
    • Minimal: reduce runtime wherever possible and remove complicated details that are irrelevant to the issue at hand.
    • Readable: format your code according to the tidyverse style guide.

Description

I have a large (for me) plan with about 100 targets. While working on it, I had some subtly invalid code. The code parsed with the R parser, but it was definitely an error on my part. When I tried to run the plan, I got the error below. It took me a bit of time to find the problem because the error didn't give any real hints of where the problem started.

The request is to catch coding errors like this and give a more informative error than "subscript out of bounds".

Reproducible example

library(drake)

foo <- function() {
  # Whoops, that plus sign at the end of the line was not intended
  scale_y_log10() +
    mod <- list()
}

make(drake_plan(bar=foo()))
#> Error in e[[2]]: subscript out of bounds

Created on 2021-07-01 by the reprex package (v2.0.0)

@wlandau
Copy link
Member

wlandau commented Jul 2, 2021

This error happens during drake's static code analysis to detect dependencies. Error messages are now improved:

foo <- function() scale_y_log10() + mod <- list()
drake::make(drake::drake_plan(bar = foo()))
#> Error: subscript out of bounds
#> Malformed code:
#> scale_y_log10() + mod <- list()
#> 
#> Malformed code:
#> function ()  scale_y_log10() + mod <- list()

Created on 2021-07-02 by the reprex package (v2.0.0)

@billdenney
Copy link
Contributor Author

Thanks!

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

No branches or pull requests

2 participants