You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've made a reprex below showing that the tag's $val which appears to be a "" is not actually a "". This causes the roxy_tag_ns.roxy_tag_export function logic to fail.
tmpfile<- tempfile()
cat(file=tmpfile, "#' @export`[[<-.custom` <- function(a,b,c) { a}#' @export`[<-.custom` <- function(a,b,c) { a}"
)
blocks<-roxygen2::parse_file(tmpfile)
blocks#> [[1]]#> <roxy_block> [file11399528b5575:3]#> $tag#> [line: 2] @export '' {parsed}#> [????:???] @usage '<generated>' {parsed}#> [????:???] @.formals '<generated>' {parsed}#> [????:???] @backref '/var/folders/0k/bxg5lhr92sq74mb1d446ql540000gp/...' {parsed}#> $call `[[<-.custom` <- function(a, b, c) { ...#> $object <s3method> #> $topic [[<-.custom#> $alias [[<-.custom#> #> [[2]]#> <roxy_block> [file11399528b5575:8]#> $tag#> [line: 7] @export '' {parsed}#> [????:???] @usage '<generated>' {parsed}#> [????:???] @.formals '<generated>' {parsed}#> [????:???] @backref '/var/folders/0k/bxg5lhr92sq74mb1d446ql540000gp/...' {parsed}#> $call `[<-.custom` <- function(a, b, c) { ...#> $object <s3method> #> $topic [<-.custom#> $alias [<-.custom# Unexpected behaviorroxygen2:::blocks_to_ns(blocks)
#> [1] "export(\"\")"# The values appear to be a double quoteblocks[[1]]$tags[[1]]$raw#> [1] ""blocks[[1]]$tags[[1]]$val#> [1] ""# Does not equal a double quoteblocks[[1]]$tags[[1]]$raw==""#> [1] FALSEblocks[[1]]$tags[[1]]$val==""#> [1] FALSE# Since it does not equal a `""`, the then the `identical(x$val, "")` check fails inroxygen2:::roxy_tag_ns.roxy_tag_export#> function (x, block, env, import_only = FALSE) #> {#> if (import_only) {#> return()#> }#> if (identical(x$val, "")) {#> default_export(block$object, block)#> }#> else {#> export(x$val)#> }#> }#> <bytecode: 0x7fa5114865c8>#> <environment: namespace:roxygen2># `$raw` is copied over here...roxygen2:::tag_words_line#> function (x) #> {#> x$val <- str_trim(x$raw)#> if (str_detect(x$val, "\n")) {#> roxy_tag_warning(x, "may only span a single line")#> }#> else if (!rdComplete(x$val)) {#> roxy_tag_warning(x, "mismatched braces or quotes")#> }#> else {#> x$val <- str_split(x$val, "\\s+")[[1]]#> x#> }#> }#> <bytecode: 0x7fa5211d3600>#> <environment: namespace:roxygen2># Expected behaviorfixed_blocks<-blocksfixed_blocks[[1]]$tags[[1]]$val<-""fixed_blocks[[2]]$tags[[1]]$val<-""roxygen2:::blocks_to_ns(fixed_blocks)
#> [1] "S3method(\"[<-\",custom)" "S3method(\"[[<-\",custom)"
Turns out, x$raw is not equal to "". If we call charToRaw(x$raw), I was expecting raw(0). It is actually charToRaw(x$raw) # e2 80 8b. This value is a "Zero width space". Weird!
Looking at the c++ code more, if the line below was disabled, the Zero Width Space problem would go away.
I've made a reprex below showing that the tag's
$val
which appears to be a""
is not actually a""
. This causes theroxy_tag_ns.roxy_tag_export
function logic to fail.Created on 2021-03-31 by the reprex package (v0.3.0)
I don't know if the original error is here:
roxygen2/src/parser2.cpp
Line 153 in 6c1e42f
Changing the string value to
""
fixes my problem, but is not a solution.Link to where
$val
is set (at least for my example):roxygen2/R/tag-parser.R
Lines 135 to 136 in 6c1e42f
The text was updated successfully, but these errors were encountered: