www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8915] New: Current lvalue behavior looks inconsistent for structs and buildin types

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

           Summary: Current lvalue behavior looks inconsistent for structs
                    and buildin types
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com



18:30:09 MSK ---
---
int iFunc() { return 0; };
enum int iEnum = iFunc();

struct S { }
S sFunc() { return S(); };
enum S sEnum = sFunc();

void refI(ref int) { }
void refS(ref S) { }

void main()
{
    refI(int.init);  // Error: constant 0 is not an lvalue
    refI(iEnum);     // Error: constant 0 is not an lvalue
    refI(iFunc());   // Error: iFunc() is not an lvalue

    refS(S());      // compiles
    refS(S.init);   // compiles
    refS(sFunc());  // Error: f() is not an lvalue
    refS(sEnum);    // compiles
}
---

This leads to inability to define `NonZeroUInt32` struct e.g. with same
semantics as `uint`.

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