title: Unexpected behaviour with argument defaults
body: <p>I just ran into something odd, which hopefully someone here can shed some light on. Basically, when a function has an argument whose default value is the argument's name, strange things happen (well, strange to me anyway).</p>
  
  <p>For example:</p>
  
  <pre><code>y &lt;- 5
  
  f &lt;- function(x=y) x^2
  
  f2 &lt;- function(y=y) y^2
  </code></pre>
  
  <p>I would consider <code>f</code> and <code>f2</code> to be equivalent; although they use different variable names internally, they should both pick up the <code>y</code> object in the global environment to use as the default. However:</p>
  
  <pre><code>&gt; f()
  [1] 25
  
  &gt; f2()
  Error in y^2 : 'y' is missing
  </code></pre>
  
  <p>Not sure why that is happening.</p>
  
  <p>Just to make things even more interesting:</p>
  
  <pre><code>f3 &lt;- function(y=y) y$foo
  
  &gt; f3()
  Error in f3() : 
    promise already under evaluation: recursive default argument reference or earlier problems?
  </code></pre>
  
  <p>I expected f3 to throw an error, but not that one!</p>
  
  <p>This was tested on R 2.11.1, 2.12.2, and 2.14, on 32-bit Windows XP SP3. Only the standard packages loaded.</p>