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

Should $xml_find_function_calls() be friendlier for non-syntactic calls like %%(x, y)? #2760

Open
MichaelChirico opened this issue Feb 18, 2025 · 1 comment

Comments

@MichaelChirico
Copy link
Collaborator

Now we would need to provide the backticked version:

writeLines("`%%`(x, y)", tmp<-tempfile())
e = get_source_expressions(tmp)

length(e$expressions[[1L]]$xml_find_function_calls("%%"))
# [1] 0
length(e$expressions[[1L]]$xml_find_function_calls("`%%`"))
# [1] 1

Should the former usage "just work" to save the user having to think through whether ` is needed?

@MichaelChirico
Copy link
Collaborator Author

All the more annoying is quoted non-syntacted usage:

getParseData(parse(text = "'%%'()"))
#   line1 col1 line2 col2 id parent     token terminal text
# 6     1    1     1    6  6      0      expr    FALSE     
# 1     1    1     1    4  1      3 STR_CONST     TRUE '%%'
# 3     1    1     1    4  3      6      expr    FALSE     
# 2     1    5     1    5  2      6       '('     TRUE    (
# 4     1    6     1    6  4      6       ')'     TRUE    )

But we don't handle this style basically at all. It should probably generate a keyword_quote_linter() hit:

lint(text = "'%%'()", linters = keyword_quote_linter())
# i No lints found.

I'll mention that under #2471.

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

1 participant