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

Error values must be length 1 but FUN(X[[1]]) result is length 0 #461

Closed
renkun-ken opened this issue Feb 24, 2020 · 1 comment · Fixed by #462
Closed

Error values must be length 1 but FUN(X[[1]]) result is length 0 #461

renkun-ken opened this issue Feb 24, 2020 · 1 comment · Fixed by #462

Comments

@renkun-ken
Copy link
Collaborator

From REditorSupport/languageserver#218:

Create a file diagnostics.R with the following content:

sum(1:10, na.rm += 1)

The file is obviously not parse-able but calling lintr::lint("diagnostics.R") will result in the following error:

Error in vapply(eq_assign_locs, next_with_parent, pc = pc, integer(1)) : 
  values must be length 1,
 but FUN(X[[1]]) result is length 0
Backtrace:
1: vapply(eq_assign_locs, next_with_parent, pc = pc, integer(1))
2: fix_eq_assigns(fix_column_numbers(fix_tab_indentations(source_file)))
3: get_source_file(source_file, error = lint_error)
4: get_source_expressions(filename)
5: lintr::lint("diagnostics.R")
@renkun-ken
Copy link
Collaborator Author

The simplest example to cause this error is

x=

russHyde pushed a commit that referenced this issue Mar 10, 2020
This commit fixes the handling of source code such as

`x=`, and `sum(1:10, na.rm += 1)`

for which the parse data stops at the `=` in these cases where the last token is always EQ_ASSIGN. This PR adds a condition that if the last token is EQ_ASSIGN then fix_eq_assigns should not do anything because next_with_parent no longer works.
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

Successfully merging a pull request may close this issue.

1 participant