From neal.p.richardson at gmail.com  Fri Sep  8 19:52:32 2017
From: neal.p.richardson at gmail.com (Neal Richardson)
Date: Fri, 8 Sep 2017 10:52:32 -0700
Subject: [Rd] Bug: dput/deparse with named character vector inside list
Message-ID: <CAOCv4hioP-To2r0cxRtMyEAGGFvHNBDQ0J_2WTOEegUVxzP3ug@mail.gmail.com>

Hi,
I noticed some R-devel failures on CRAN on a package I maintain:
https://cloud.r-project.org/web/checks/check_results_httptest.html

It appears that 'dput'/'deparse' is returning an invalid object when
there is a named character vector inside a list. Here is a minimal
example that reproduces the issue:

> z <- list(a=c(b="foo"))
> str(z)
List of 1
 $ a: Named chr "foo"
  ..- attr(*, "names")= chr "b"

> dput(z)
list(a = b = "foo")
> parse(text=deparse(z))
Error in parse(text = deparse(z)) : <text>:1:12: unexpected '='
1: list(a = b =
               ^

But it works fine if you just provide a named character vector:


> dput(z$a)
structure("foo", .Names = "b")


I know that there were some recent improvements to 'deparse' (c73120,
73144). Among the failures on my package on R-devel on CRAN, a test
run on version as old as r73150 does manifest this bug
(https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-fedora-gcc/httptest-00check.html),
so the timing does suggest that those changes could be related.

Neal


> sessionInfo()
R Under development (unstable) (2017-09-07 r73219)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] compiler_3.5.0



[Rd] Bug: dput/deparse with named character vector inside list
Neal Richardson