Thread overview
[Issue 1407] New: auto type inference on new const(Class)() doesn't infer const
Aug 09, 2007
d-bugmail
Aug 11, 2007
d-bugmail
Aug 11, 2007
d-bugmail
Jun 09, 2011
yebblies
August 09, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1407

           Summary: auto type inference on new const(Class)() doesn't infer
                    const
           Product: D
           Version: 2.003
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: paching@gmail.com


Also true for invariant. Sample code:

class A {}
void main() {
        auto b = new const(A)();
        auto c = new invariant(A)();
}

Gives two errors such as:
Error: cannot implicitly convert expression (new const A) of type const A to
testcase.A
Error: cannot implicitly convert expression (new invariant A) of type invariant
A to testcase.A


-- 

August 11, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1407





------- Comment #1 from baryluk@mpi.int.pl  2007-08-11 12:54 -------
Mayby extend type inference to

auto(auto) b = new const(A)();

First auto will expand to storage type, and second to name of class

This will allow to do this:

invariant(auto) b = new const(A)()

and also:

const(auto) b = new A();


-- 

August 11, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1407





------- Comment #2 from baryluk@mpi.int.pl  2007-08-11 12:56 -------
(In reply to comment #1)
> invariant(auto) b = new const(A)()

Should be:
const(auto) b = new invariant(A)()


-- 

June 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=1407


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies@gmail.com
         Resolution|                            |FIXED


--- Comment #3 from yebblies <yebblies@gmail.com> 2011-06-09 09:36:17 PDT ---
This has been fixed for a while, if you change 'invariant' to 'immutable'.

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