www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7619] New: Broken deprecated feature with template function

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

           Summary: Broken deprecated feature with template function
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: k.hara.pg gmail.com



I think following code should compile with and without -d switch.

test.d
----
void main(){}

void foo(T)(T t){}  // line 3

deprecated struct S{}

deprecated void test()
{
    S s;
    foo(s);   // line 10
    // foo is instantiated with deprecated struct S.
}

command line
----
dmd -run test.d

output:
----
test.d(3): Error: struct test.S is deprecated
test.d(10): Error: template instance test.foo!(S) error instantiating

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


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com



It seems to me the compiler generates

void fooS(S t) {}

but once the time's come to semantically analyse the instance, it has forgotten
what created it in the first place.

Perhaps what's needed is: If when semantically analysing a template instance a
deprecated symbol is hit, flag the template instance as deprecated.  Then only
if non-deprecated code references it will an error be generated.

The complication is that the error shown to the user should be about the
original deprecated symbol.  This can be achieved by accommodating in the
propagated deprecation flag a note of the original deprecation.

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