Skip to content

[RDataFrame] Do not transform #var inside string literals (fixes #23790) - #23800

Closed
muntasir-396 wants to merge 1 commit into
root-project:masterfrom
muntasir-396:fix/rdf-string-literal-hash
Closed

muntasir-396 wants to merge 1 commit into
root-project:masterfrom
muntasir-396:fix/rdf-string-literal-hash

Conversation

@muntasir-396

Copy link
Copy Markdown
Contributor

Summary

Fixes #23790.

Problem

In RDataFrame expressions, #var is an alias for R_rdf_sizeof_var.
Previously, a global regex substitution was run over the raw expression string, modifying # characters inside string literals (e.g. printString("#a") turned into printString("R_rdf_sizeof_a")).

Solution

  • Introduced ReplaceHashVarOutsideLiterals in RDFInterfaceUtils.cxx which scans the expression for string literals ("..."), raw string literals (R"(...)"), character literals ('...'), and comments, and only performs the #var alias replacement on tokens outside literals.
  • Added regression test ShortSyntaxRespectsStringLiterals in dataframe_interface.cxx.

Checklist

  • Tested with regular string literals, raw string literals, and escaped quotes
  • Added unit test to dataframe_interface.cxx

…-project#23790)

In RDataFrame expressions, #var is an alias for R_rdf_sizeof_var.
Previously, a global regex replacement was applied over the entire expression,
erroneously modifying '#' characters inside string literals (e.g. "#a" -> "R_rdf_sizeof_a").

This change introduces ReplaceHashVarOutsideLiterals, which skips string literals,
raw string literals, character literals, and comments when expanding #var aliases.
Added regression test ShortSyntaxRespectsStringLiterals in dataframe_interface.cxx.
@vepadulano

Copy link
Copy Markdown
Member

Dear @muntasir-396 ,

Thanks for showing interest in the project and submitting this PR! I believe the proposed changes introduce more code than necessary, I proposed a different approach that should supersede this PR at #23804

@muntasir-396

Copy link
Copy Markdown
Contributor Author

Thank you @vepadulano sir, for taking the time to review my PR and for suggesting an alternative approach. I appreciate your feedback. I’ll review PR #23804 to better understand the approach and learn from it. Thanks again for your guidance!

@vepadulano vepadulano closed this Oct 23, 2026
@vepadulano

Copy link
Copy Markdown
Member

@muntasir-396 just FYI I added back your test which is a more direct check of the original issue to #23804

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 this pull request may close these issues.

[RDataFrame] Code that transforms #var alias to R_rdf_sizeof_var does not respect string literals

2 participants