title: BrightScript function returning string sometimes returns itself (the function)
body: <p>Sometimes when a BrightScript function, that is supposed to return <code>invalid</code> or a <code>string</code>, returns, it does not return either invalid nor a string, but instead it (seem as it) returns the type <code>Function</code>. I haven't been able to track down <em>why</em> or <em>when</em> but it seems pretty arbitrary a for the <em>when</em>.
  This is such a function.</p>
  
  <pre><code>function RegRead(key, section = invalid)
    if section = invalid section = "Default"
    sec = CreateObject("roRegistrySection",section)
    if sec.Exists(key)
      return sec.Read(key)
    end if
    return invalid
  end function
  </code></pre>
  
  <p>I call it something like this</p>
  
  <pre><code>val = RegRead("code")
  </code></pre>
  
  <p>What's going on? Is this a BrightScript bug?</p>