r-lib / prettycode

Syntax highlight R code in the terminal
https://r-lib.github.io/prettycode/
Other
101 stars 9 forks source link

Do not print external pointer #3

Closed randy3k closed 6 years ago

randy3k commented 6 years ago

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>)
gaborcsardi commented 6 years ago

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