Skip to content

Upcoming fix in R devel parser requires action #419

Closed
@lorenzwalthert

Description

@lorenzwalthert
> getParseData(parse(text = "t = 1")) 
# current R 3.5.1
  line1 col1 line2 col2 id parent     token terminal text
1     1    1     1    1  1      3    SYMBOL     TRUE    t
3     1    1     1    1  3      0      expr    FALSE
2     1    2     1    2  2      0 EQ_ASSIGN     TRUE    =
4     1    3     1    3  4      5 NUM_CONST     TRUE    1
5     1    3     1    3  5      0      expr    FALSE

# R devel after committed by Tomas Kalibera
  line1 col1 line2 col2 id parent        token terminal text
8     1    1     1    3  8      0 equal_assign    FALSE <==== I added this
1     1    1     1    1  1      3       SYMBOL     TRUE    t
3     1    1     1    1  3      8         expr    FALSE
2     1    2     1    2  2      8    EQ_ASSIGN     TRUE    =
4     1    3     1    3  4      5    NUM_CONST     TRUE    1
5     1    3     1    3  5      8         expr    FALSE

Note the new token, which is not an expr and that all ids are changed. I was notified by the creator of the bug fix Tomas Kalibera as this will cause R CMD CHECK of styler (and reverse dependencies) to fail on R devel.

I see the following solution: Nest the parse data as is. Then, don't relocate the EQ_ASSIGN if a token equal_assign is present in a nest.

relocate_eq_assign <- function(pd) {
  if (any(pd$token == "equal_assign")) {
    pd
  } else {
    pd %>%
      post_visit(c(relocate_eq_assign_nest))
  }
}

@krlmlr what do you think should we do? Should we wait until the bug fix of the base R parser is implemented in R devel, fix the problem here and create a new release? I think I can't guarantee that this works and submit before the changes are implemented in R devel and I won't build R devel myself.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions