title: byref return in F# 4.5
body: <p>I am trying to add a F#-style interface to a type, that has a byref return method.
  Here's the code:</p>
  
  <pre><code>type IPool&lt;'P, 'T when 'T: struct&gt; =
    abstract member GetReference: ITypedPointer&lt;'P, 'T&gt; -&gt; byref&lt;'T&gt;
  
  let Ref&lt;'TPool, 'P, 'T when 'TPool :&gt; IPool&lt;'P, 'T&gt;&gt; (pool: 'TPool) pointer =
    pool.GetReference pointer
  </code></pre>
  
  <p>Now to my surprise, a similar thing worked fine until I introduced <code>IPool</code> interface. Before that Ref itself contained an implementation like <code>&amp;pool.data.[idx]</code>, and worked fine.</p>
  
  <p>I tried installing nightly build of F# Tools, cause latest release does not officially support byref returns, and PR to introduce them was recently completed: <a href="https://github.com/Microsoft/visualfsharp/pull/4888" rel="nofollow noreferrer">https://github.com/Microsoft/visualfsharp/pull/4888</a></p>
  
  <p>However, I still get <code>error FS3209: The address of the variable 'copyOfStruct' cannot be used at this point. A method or function may not return the address of this local value.</code> in Visual Studio. Type <code>outref&lt;T&gt;</code> still does not seem to be available either. Am I missing something?</p>
  
  <p>I also tried to drop the <code>pointer</code> parameter, and just return <code>pool.GetReference</code> to only get a different error message.</p>
  
  <p>Addition: the ultimate goal is to be able to do</p>
  
  <pre><code>let aref = Ref pool ptr
  let bref = Ref pool ptr
  aref &lt;- 42
  assert(aref = bref)
  </code></pre>
  
  <p>e.g. give caller a direct reference to an internal memory, usually backed by an array, similar to <code>Span&lt;T&gt;</code>. I am making this for performance reasons, so it is not OK to allocate on every call to Ref.</p>