title: rlang: Error: Can't convert a function to a string
body: <p>I created a function to convert a function name to string. Version 1 <code>func_to_string1</code> works well, but version 2 <code>func_to_string2</code> doesn't work.</p>
  
  <pre><code>func_to_string1 &lt;- function(fun){
      print(rlang::as_string(rlang::enexpr(fun)))
  }
  
  func_to_string2 &lt;- function(fun){
      is.function(fun)
      print(rlang::as_string(rlang::enexpr(fun)))
  }
  </code></pre>
  
  <p><code>func_to_string1</code> works:</p>
  
  <pre><code>&gt; func_to_string1(sum)
  [1] "sum"
  </code></pre>
  
  <p><code>func_to_string2</code> doesn't work.</p>
  
  <pre><code>&gt; func_to_string2(sum)
   Error: Can't convert a primitive function to a string
  Call `rlang::last_error()` to see a backtrace 
  
  </code></pre>
  
  <p>My guess is that by calling the <code>fun</code> before converting it to a string, it gets evaluated inside function and hence throw the error message. But why does this happen since I didn't do any assignments?</p>
  
  <p>My questions are why does it happen and is there a better way to convert function name to string?</p>
  
  <p>Any help is appreciated, thanks!</p>