reprex icon indicating copy to clipboard operation
reprex copied to clipboard

Parse error when braces are on a separate line

Open billdenney opened this issue 4 years ago • 0 comments

When braces are on a separate line (see the suppressWarnings() difference where braces are on the same line vs. different lines at the top), reprex can generate a parse error:

The first example fails to parse with the error:

i Rendering reprex...
Error in parse(text = x, keep.source = TRUE) : 
  <text>:11:3: unexpected symbol
10:   rlang::warn("show this")
11:   rlang
      ^
reprex::reprex({
rlang::warn("show this")
rlang::warn("hide this", class="hider")

suppressWarnings(
{
  rlang::warn("show this")
  rlang::warn("hide this", class="hider")
},
classes="hider")
})

The second example where the { is on the same line as suppressWarnings( succeeds:

rlang::warn("show this")
#> Warning: show this
rlang::warn("hide this", class="hider")
#> Warning: hide this

suppressWarnings({
  rlang::warn("show this")
  rlang::warn("hide this", class="hider")
},
classes="hider")
#> Warning: show this

Created on 2021-08-01 by the reprex package (v2.0.0)

billdenney avatar Aug 02 '21 01:08 billdenney