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

malformed raw string literal not captured #892

Closed
renkun-ken opened this issue Dec 18, 2021 · 2 comments · Fixed by #895
Closed

malformed raw string literal not captured #892

renkun-ken opened this issue Dec 18, 2021 · 2 comments · Fixed by #895

Comments

@renkun-ken
Copy link
Collaborator

The syntax error of the raw string in the following code is not captured:

line1 <- 1
line2 <- 2
line3 <- 3
line4 <- R"--/hello/--"

where error has the number of line:

malformed raw string literal at line 4
@MichaelChirico
Copy link
Collaborator

Could you elaborate on what's the error here?

Here's what I get at HEAD:

lintr::lint('line1 <- 1
line2 <- 2
line3 <- 3
line4 <- R"--/hello/--"')
# <text>:1:1: error: malformed raw string literal at line 4
# 
# ^
dput(.Last.value)
# structure(list(structure(list(filename = "<text>", line_number = 1L, 
#     column_number = 1L, type = "error", message = "malformed raw string literal at line 4", 
#     line = "", ranges = NULL, linter = NA_character_), class = "lint")), class = "lints")

Just that the line_number is incorrect?

@renkun-ken
Copy link
Collaborator Author

Just that the line_number is incorrect?

Yes. Should be titled that the line number is not captured.

AshesITR added a commit that referenced this issue Feb 15, 2022
* Improve line location information for R parse errors

I chose to use a script in `data-raw` to auto-generate the required parse error regexes and store them in .parse_error_regexes in `R/sysdata.rda`.
`get_source_expressions()` then uses a for-loop after the initial (manual) message checks to see if a parse error with line information was matched.

Fixes #892
Fixes #894

 * [x] implement
 * [x] add tests
 * [x] add NEWS bullet

* fix auto-wrap

* fix double-escape for \ in regexes

add tests for one-past EOF line number and for \ in error message

* improve message extraction

* change approach to generic regex without sysdata

* incorporate review suggestions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants