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

Losing argument names in [ call #68

Closed
krlmlr opened this issue Oct 15, 2022 · 4 comments
Closed

Losing argument names in [ call #68

krlmlr opened this issue Oct 15, 2022 · 4 comments
Milestone

Comments

@krlmlr
Copy link
Contributor

krlmlr commented Oct 15, 2022

This one seems fun, for some definition of fun. With most recent #56, 94bb159:

fun <- parse(keep.source = FALSE, srcfile = "test.R", text = "function() df[1, 1, drop = FALSE]")[[1]]
fun
#> function() df[1, 1, drop = FALSE]

constructive::construct(fun, check = TRUE)
#> quote(function() df[1, 1, FALSE])
#> Error in `check_round_trip()` at constructive/R/constructive.R:63:2:
#> ! {constructive} couldn't create code that reproduces perfectly the input
#> `original`:  `function() df[1, 1, drop = FALSE]`
#> `recreated`: `function() df[1, 1, FALSE]`

#> Backtrace:
#>     ▆
#>  1. └─constructive::construct(fun, check = TRUE)
#>  2.   └─constructive:::check_round_trip(...) at constructive/R/constructive.R:63:2
#>  3.     └─rlang::abort(c(msg)) at constructive/R/constructive.R:159:4

Created on 2022-10-15 with reprex v2.0.2

@krlmlr
Copy link
Contributor Author

krlmlr commented Oct 15, 2022

It's not styler:

styler::style_text("function() df[1, 1, drop = FALSE]")
#> function() df[1, 1, drop = FALSE]

Created on 2022-10-15 with reprex v2.0.2

@moodymudskipper
Copy link
Collaborator

Minimal reprex:

constructive::deparse_call(quote(a[b=1]))
#> a[1] 

@moodymudskipper
Copy link
Collaborator

Names were not considered with [ and [[

New behaviour:

fun <- parse(keep.source = FALSE, srcfile = "test.R", text = "function() df[1, 1, drop = FALSE]")[[1]]
fun
#> function() df[1, 1, drop = FALSE]

constructive::construct(fun, check = TRUE)
#> quote(function() df[1, 1, drop = FALSE])

Created on 2022-10-15 with reprex v2.0.2

@moodymudskipper moodymudskipper added this to the 0.1 milestone Oct 15, 2022
@krlmlr
Copy link
Contributor Author

krlmlr commented Oct 15, 2022

Seems to work now, thanks.

@krlmlr krlmlr closed this as completed Oct 15, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants