www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8307] New: inconsistent treatment of auto functions

http://d.puremagic.com/issues/show_bug.cgi?id=8307

           Summary: inconsistent treatment of auto functions
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: timon.gehr gmx.ch



function.html states:
"Auto Functions

Auto functions have their return type inferred from any ReturnStatements in the
function body.

An auto function is declared without a return type. If it does not already have
a storage class, use the auto storage class.

If there are multiple ReturnStatements, the types of them must match exactly.
If there are no ReturnStatements, the return type is inferred to be void. "

DMD sez:

auto foo(){ return 0; return 0.0; } // ok

auto bar(int x){ if(x==0) return 0; return bar(x-1)+1; } // error

The compiler, the documentation or both need to be fixed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 27 2012