www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8289] New: Cannot declare functions returning anonymous enum if they have 'in' block.

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8289

           Summary: Cannot declare functions returning anonymous enum if
                    they have 'in' block.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: mp81ss rambler.ru



import std.stdio;

enum { A, B };

/*
If I replace the return type int with enum, doesn't compile.
If I remove the in/body blocks and declare a contractless f, both enum/int are
ok.
*/
int dummy(in int i)
in {
    assert(i > 0);
}
body {
    return A;
}

void main()
{
    immutable x = dummy(0);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 23 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8289


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |INVALID



06:07:23 PST ---
Maybe you're misreading the runtime assert error as a compiler error?

OTOH if you're trying to declare the return type as 'A', that won't work
because A is not a type.

Unfortunately DMD allows nonsense like this:

enum dummy(in int i) { }

The 'enum' here acts as a placeholder as if you've declared it 'auto'.

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