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

R 4.2: Support new pipe placeholder syntax #10757

Closed
cderv opened this issue Mar 9, 2022 · 8 comments
Closed

R 4.2: Support new pipe placeholder syntax #10757

cderv opened this issue Mar 9, 2022 · 8 comments
Assignees
Labels
backport Issues whose associated fixes will need to be backported for a previous release. enhancement r versions

Comments

@cderv
Copy link
Collaborator

cderv commented Mar 9, 2022

Coming to R 4.2 is the new pipe with now a placeholder syntax

New pipe support has been added in

Now you can also use a paceholder

mtcars |> subset(cyl == 4) |> lm(mpg ~ disp, data = _)

Example here: https://twitter.com/henrikbengtsson/status/1501306369319735300
Added in : wch/r-source@587244f

Currently, the IDE is throwing a "Unexpected token error"
image

Opening the issue just to be sure it is on your radar.

@ronblum
Copy link
Contributor

ronblum commented Mar 9, 2022

Triage: Would this need to be backported?

@ronblum ronblum added the triage label Mar 9, 2022
@jmcphers
Copy link
Member

jmcphers commented Mar 9, 2022

Yes, we'd want to backport it to supported releases.

@ronblum ronblum added the backport Issues whose associated fixes will need to be backported for a previous release. label Mar 9, 2022
@kevinushey kevinushey self-assigned this Mar 9, 2022
@kevinushey
Copy link
Contributor

kevinushey commented Mar 9, 2022

I'll take a look. (We'll probably support _ in the tokenizer in all places for backport, and then consider a change in SW where the diagnostics engine warns if _ is used in an incorrect context.)

@mikebessuille
Copy link
Contributor

we want to backport this (PT includes some support for R4.2) but don't need to urgently backport this into 2022.02.1

@ronblum
Copy link
Contributor

ronblum commented Apr 14, 2022

Testing with the following examples (details to follow):

R Source

# Example of of native pipe placeholder orig. from pipeOp
mtcars |> subset(cyl == 4) |> lm(mpg ~ disp, data = _)

# Example from QA notes
mtcars |> summary(object = _)

# Making sure that putting the entire statement in a function doesn't matter
fc <- function(c){
  mtcars |> subset(cyl == 4) |> lm(mpg ~ disp, data = _)
}
fc(1)

# Also making sure that putting the statement in a function doesn't matter
fd <- function(d){
  mtcars |> summary(object = _)
}
fc(1)

# Using a user-defined function
fab <- function(a, b){
  print(b)
}
12 |> fab(1, b = _)

R Markdown

---
title: "Placeholder"
author: "New Pipe"
date: '2022-04-14'
output: html_document
---

```{r}
# Example of of native pipe placeholder orig. from pipeOp
mtcars |> subset(cyl == 4) |> lm(mpg ~ disp, data = _)

# Example from QA notes
mtcars |> summary(object = _)

# Making sure that putting the entire statement in a function doesn't matter
fc <- function(c){
  mtcars |> subset(cyl == 4) |> lm(mpg ~ disp, data = _)
}
fc(1)

# Also making sure that putting the statement in a function doesn't matter
fd <- function(d){
  mtcars |> summary(object = _)
}
fc(1)

# Using a user-defined function
fab <- function(a, b){
  print(b)
}
12 |> fab(1, b = _)
```

@ronblum
Copy link
Contributor

ronblum commented Apr 14, 2022

Tested in:

  • RStudio Desktop 2022.02.2+481 & 2022.6.0+296 on MacOS 12.3 with R 4.2.0
  • RStudio Server 2022.6.0+296 on Ubuntu 20.04 with R 4.1.2

[Ghost Orchid patch 3 TBD]

Results:

  1. The new native pipe operator's placeholder (_) is no longer identified as an image error
    (cf. to 2022.02.1+461 as a baseline).
  2. There's no difference between the R script and R Markdown.
  3. There's no difference between R versions—we treat the placeholder as not-an-error regardless, even though it's only supported by R 4.2.0.
  4. However, while this example is treated as fine:
    mtcars |> subset(cyl == 4) |> lm(mpg ~ disp, data = _)
    this example has a "no symbol named '_' in scope" image warning associated with it:
    mtcars |> summary(object = _)

placeholder_warning

@ronblum ronblum self-assigned this Apr 14, 2022
@ronblum
Copy link
Contributor

ronblum commented Apr 14, 2022

I think we don't want to show this warning, either, so putting this back into "in progress." But I can open a separate issue for this instead, since at least we're no longer flagging this as an error.

@ronblum
Copy link
Contributor

ronblum commented Apr 20, 2022

Verified fixed in RStudio Desktop 2021.09.3-395, 2022.02.2-485, and 2022.06.0-313.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Issues whose associated fixes will need to be backported for a previous release. enhancement r versions
Projects
None yet
Development

No branches or pull requests

7 participants