www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11785] New: Order of method/function declarations has an effect on compilation result.

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

           Summary: Order of method/function declarations has an effect on
                    compilation result.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: kdmult ya.ru


--- Comment #0 from kdmult <kdmult ya.ru> 2013-12-20 01:11:07 PST ---
If the templated overloaded method/function goes after the 
non-templated one then the compilation fails.
FAILED:
long read( ubyte* bytes, long len ) { return 0; }
void read(T)( ref T val ) { read(cast(ubyte*)&val, cast(long)val.sizeof); }

Otherwise, if the templated overloaded function goes before the 
non-templated one then the compilation is successful.
SUCCEEDED:
void read(T)( ref T val ) { read(cast(ubyte*)&val, cast(long)val.sizeof); }
long read( ubyte* bytes, long len ) { return 0; }

Test case 1.
---
module test;

class InputStream
{
    long read( ubyte* bytes, long len ) { return 0; }
    void read(T)( ref T val ) { read(cast(ubyte*)&val, cast(long)val.sizeof); }
}

void main()
{
    auto input = new InputStream;
    int v;
    input.read(v);
}
---

Test case 2
---
module test;

long read( ubyte* bytes, long len ) { return 0; }
void read(T)( ref T val ) { read(cast(ubyte*)&val, cast(long)val.sizeof); }

void main()
{
    int v;
    read(v);
}
---

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 20 2013
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11785


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2013-12-20 02:07:52 PST ---
https://github.com/D-Programming-Language/dmd/pull/2993

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11785



--- Comment #2 from github-bugzilla puremagic.com 2013-12-20 23:56:50 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/bdf6d81f723b33c10c84cfebef3e22ade94d32e2
fix Issue 11785 - Order of method/function declarations has an effect on
compilation result

https://github.com/D-Programming-Language/dmd/commit/691f08a6841acded5b403610931421cdcfb2751d
Merge pull request #2993 from 9rnsr/fix11785

Issue 11785 - Order of method/function declarations has an effect on
compilation result

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 20 2013
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11785


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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