r-lib/prettycode

Do not print external pointer

Closed this issue · 1 comments

Consider this function

f <- new("function")
body(f) <- substitute(.External(x), list(x = new("externalptr")))

And it cannot be printed properly by pretty code.

>  f
Error in parse(text = code, keep.source = TRUE) :
  <text>:2:11: unexpected '<'
1: function ()
2: .External(<
> print.default(f)
function ()
.External(<pointer: 0x0>)

Yeah, unfortunately deparse() does not work for this function, so prettycode should just catch the error and not color it.