title: Macro block unexpectedly returns [do: return value]
body: <p>I have the following definition inside a macro:</p>
  
  <pre><code>defmacro route(pattern, options \\ [], block) do
    name = "my_fun"
    def unquote(name)(var!(conn)) do
      unquote(block)
    end
  end
  </code></pre>
  
  <p>I am calling the macro with this function:</p>
  
  <pre><code>route "/" do
    conn
    |&gt; put_resp_content_type("text/plain")
    |&gt; send_resp(200, "Hello, world!")
  </code></pre>
  
  <p>The inner block is returning a <code>%Plug.Conn{}</code> struct, but when I print the results of <code>unquote(block)</code> in my macro, I get <code>[do: %Plug.Conn{}]</code> What am I doing wrong? Where did the <code>do</code> keyword list come from?</p>
  
  <h3>Larger snippet</h3>
  
  <pre><code>defmacro route(pattern, options \\ [], block) do
    name = Keyword.get_lazy(options, :name, fn -&gt; create_name(pattern, options) end)
    route = {pattern, name}
    quote do
      @routes [unquote(route) | @routes]
      def unquote(name)(var!(conn)) do
        resp = unquote(block)
        IO.puts("outside the block, resp is")
        IO.inspect(resp)
      end
    end
  end
  </code></pre>
  
  <hr>
  
  <pre><code>route "/" do
    resp = conn
    |&gt; put_resp_content_type("text/plain")
    |&gt; send_resp(200, "Hello, world!")
    IO.puts("Inside the block, resp is")
    IO.inspect(resp)
    resp
  end
  </code></pre>
  
  <h3>Results</h3>
  
  <pre><code>Inside the block, resp is
  %Plug.Conn{
    adapter: {Plug.Adapters.Cowboy2.Conn, :...},
    assigns: %{},
    {....SNIP....}
  }
  
  outside the block, resp is
  [
    do: %Plug.Conn{
      adapter: {Plug.Adapters.Cowboy2.Conn, :...},
      assigns: %{},
      {....SNIP....}
    }
  ]
  </code></pre>