title: Finding all variables created by assignment - Not working for pairlist
body: <p>I'm currently doing <a href="https://adv-r.hadley.nz/expressions.html#expression-special" rel="nofollow noreferrer">Advanced-R, 18 Expressions</a>. </p>
  
  <p>Topic is about 18.5.2 Finding all variables created by assignment, but the given code doesn't work in the case of pairlist.</p>
  
  <p>I followed all the given codes, but the results are not quite same with what I expect.</p>
  
  <p>To begin with, in order to figure out what the type of the input, <code>expr_type()</code> is needed.</p>
  
  <pre class="lang-r prettyprint-override"><code>expr_type &lt;- function(x) {
      if(rlang::is_syntactic_literal(x)) {
          "constant"
      } else if (is.symbol(x)) {
          "symbol"
      } else if (is.call(x)) {
          "call"
      } else if (is.pairlist(x)) {
          "pairlist"
      } else {
          typeof(x)
      }
  }
  </code></pre>
  
  <p>And the author, hadley, coupled this with a wrapper around the switch function.</p>
  
  <pre class="lang-r prettyprint-override"><code>switch_expr &lt;- function(x, ...) {
    switch(expr_type(x),
      ...,
      stop("Don't know how to handle type ", typeof(x), call. = FALSE)
    )
  }
  </code></pre>
  
  <p>In the case of base cases, symbol and constant, is trivial because neither represents assignment. </p>
  
  <pre class="lang-r prettyprint-override"><code>find_assign_rec &lt;- function(x) {
    switch_expr(x,
      constant = ,
      symbol = character()
    )
  }
  </code></pre>
  
  <p>In the case of recursive cases, especially for pairlists, he suggested</p>
  
  <pre class="lang-r prettyprint-override"><code>flat_map_chr &lt;- function(.x, .f, ...) {
    purrr::flatten_chr(purrr::map(.x, .f, ...))
  }
  </code></pre>
  
  <p>So summing up, it follows</p>
  
  <pre class="lang-r prettyprint-override"><code>find_assign_rec &lt;- function(x) {
    switch_expr(x,
      # Base cases
      constant = ,
      symbol = character(),
  
      # Recursive cases
      pairlist = flat_map_chr(as.list(x), find_assign_rec),
    )
  }
  
  find_assign &lt;- function(x) find_assign_rec(enexpr(x))
  </code></pre>
  
  <p>Then, I expect in the case of <code>pl &lt;- pairlist(x = 1, y = 2)</code>, <code>find_assign(pl)</code> should return <code>#&gt; [1] "x" "y"</code></p>
  
  <p>But the actual output is <code>character(0)</code></p>
  
  <p>What is wrong with this?</p>