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

Equal assign r36 bug #6

Merged
merged 7 commits into from
Aug 14, 2019
Merged

Conversation

russHyde
Copy link

@russHyde russHyde commented Aug 13, 2019

Following up on a bug in R3.6 #5
that meant xml_parse_data(parse(text = "a = 1")) couldn't be converted
to valid xml (although this could be parsed in R3.5 using xml_parse_data).

This appears to result from changes to getParseData in R3.6.

Expressions can be nested inside each other in the data returned by
getParseData() in such a way that the end position of the nested
expressions are identical.

For example, the code above gets parsed into the following subtree
(approximately) by getParseData(). In it, `equal_assign` and `expr[2]`
end at the same position in the code above (relevant in R3.6).
- equal_assign:
    - expr[1]:
        - SOME_SYMBOL
    - EQ_ASSIGN
    - expr[2]:
        - SOME_VALUE

xml-termini for `equal_assign` and both `expr` nodes are added
while running xml_parse_data; but these termini were originally
sorted such that that for `equal_assign` came before the second
`expr`. Like: `<equal_assign>...<expr[2]></equal_assign></expr[2]>`.

The xml-termini for each expression are now sorted by the start
position of the expressions (in addition to their other
coordinates).

[not sure I've explained the problem / fix particularly well; apologies]

`getParseData()` has a new `token` type in R3.6: `equal_assign`.

`xml_parse_data(parse(text = "a = 1", keep.source = TRUE))` was
returning invalid xml when ran in R 3.6. A test that captures this
was added.
Expressions can be nested inside each other in the data returned by
getParseData() in such a way that the end position of the nested
expressions are identical.

For example, `equal_assign` and `expr[2]` end at the same position
in the following (relevant in R3.6).
- equal_assign:
    - expr[1]:
        - SOME_SYMBOL
    - EQ_ASSIGN
    - expr[2]:
        - SOME_VALUE

xml-termini for `equal_assign` and both `expr` nodes are added
while running xml_parse_data; but these termini were originally
sorted such that that for `equal_assign` came before the second
`expr`. Like: `<equal_assign>...<expr[2]></equal_assign></expr[2]>`.

The xml-termini for each expression are now sorted by the start
position of the expressions (in addition to their other
coordinates).
@russHyde
Copy link
Author

The CI failed for R-3.1 but passed for all other releases.

I don't think I'll be able to get it to pass CI on R 3.1 since covr ('suggest'ed by xmlparsedata) imports httr (which requires R >= 3.2).

Is there a way to run the CI for R 3.1 such that only the xmlparsedata 'import's are required?

@jimhester
Copy link
Member

@russHyde, we can drop 3.1 compatibility.

R/package.R Outdated
## - the terminal nodes from pd2 may be nested inside each other, when
## this happens they will have the same line1, col1, line2, col2 and
## terminal status; and 'start' is used to break ties
ord <- with(pd, order(line1, col1, -line2, -col2, terminal, -start))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general using with() in packages is not recommended, mainly because it will generate a NOTE about global variables, which you then have to whitelist with utils::globalVariables(). I think you should convert this to

pd <- pd[ order(pd$line1, pd$col1, -pd$line2, -pd$col2, pd$terminal, -start), ]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do (but will use -pd$start)

Copy link
Member

@jimhester jimhester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good, I made a small suggestion inline.

Can you please add a bullet to NEWS? It should briefly describe the change and end with (@yourname, #issuenumber).

@russHyde
Copy link
Author

Thanks @jimhester .

Would you be happy for me to move the new test into test/testthat/test.R and drop the test-debug...R file? (I'll reduce the comment volume within the new test as well).

@codecov-io
Copy link

Codecov Report

Merging #6 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master     #6   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           2      2           
  Lines          58     56    -2     
=====================================
- Hits           58     56    -2
Impacted Files Coverage Δ
R/package.R 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 99a30b1...e54f28e. Read the comment docs.

@russHyde
Copy link
Author

Have made the requested changes. Regards

@gaborcsardi gaborcsardi merged commit af0f0cf into r-lib:master Aug 14, 2019
@gaborcsardi
Copy link
Member

Thanks much!

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.

4 participants