Skip to content

convert.expr: split expressions containing ^, - in parentheses and [ ] - #4257

Draft
madhavzanwar wants to merge 4 commits into
PecanProject:developfrom
madhavzanwar:GH-4216-convert-expr-special-chars
Draft

madhavzanwar wants to merge 4 commits into
PecanProject:developfrom
madhavzanwar:GH-4216-convert-expr-special-chars

Conversation

@madhavzanwar

Copy link
Copy Markdown
Contributor

Fixes #4216

What

convert.expr() built a regular-expression character class from the operator characters it found in the expression, so ^, - and [ ] (special inside a character class) broke the split: b^2+c returned "+", x^2 raised an error and (b-c)*d returned "b-c" as one variable. It now splits on the fixed class [^a-zA-Z0-9_.]. A plain variable name is returned unchanged. NEWS and CHANGELOG entries added.

Testing

The new test (four expressions plus a plain name) fails on develop and passes with the fix; all of test.utils.R passes

convert.expr() built a regex character class from the operators it found, so ^, - and [ ] inside an expression broke the split. Split on the fixed class [^a-zA-Z0-9_.] instead.

Fixes PecanProject#4216
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

convert.expr() mis-splits expressions containing ^, - in parentheses, or [ ]

1 participant