Thread overview
[Issue 6661] New: Templates instantiated only through is(typeof()) shouldn't cause errors
Sep 13, 2011
Don
Sep 14, 2011
Walter Bright
Sep 15, 2011
Walter Bright
Sep 15, 2011
Denis
Oct 17, 2011
Walter Bright
Mar 21, 2012
Don
September 13, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6661

           Summary: Templates instantiated only through is(typeof())
                    shouldn't cause errors
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: clugdbug@yahoo.com.au


--- Comment #0 from Don <clugdbug@yahoo.com.au> 2011-09-13 02:44:40 PDT ---
The template blaz!int cannot be instantiated without errors, because it contains an assignment of a string literal to int. But, since it is not actually instantiated, it shouldn't cause a compile error.

template blaz(Q)
{
    int qutz(Q y)
    {
        Q q = "abc";
        return 67;
    }
    static assert(qutz(13).sizeof!=299);
    const Q blaz = 6;
}

static assert(is(typeof(blaz!(int).blaz)));

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 14, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6661


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2011-09-14 00:45:10 PDT ---
D2 fix: https://github.com/D-Programming-Language/dmd/commit/0a927f258e89f92f280c0e855a93ceb05e34a260

Partial D1 fix: https://github.com/D-Programming-Language/dmd/commit/31d6751de3a877c72055a2096a9a9c4a9a25ec9b

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6661


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2011-09-15 11:24:07 PDT ---
D1 fix: https://github.com/D-Programming-Language/dmd/commit/23846aca52ebd21efab36ff32924c5a6cc17c4c0

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6661


Denis <verylonglogin.reg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |verylonglogin.reg@gmail.com
         Resolution|FIXED                       |


--- Comment #3 from Denis <verylonglogin.reg@gmail.com> 2011-09-15 13:13:15 PDT ---
Still in dmd-1.x branch (tested after fe308a1).
Compiler fails with exit code 1 and no error messages.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 17, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6661


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2011-10-16 22:51:56 PDT ---
https://github.com/D-Programming-Language/dmd/commit/7654a72e61b1ae322b9f55bbff97ea1c36db4622

https://github.com/D-Programming-Language/dmd/commit/fd5399a4899da09d7a35e2258a5fa92139e4d292

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6661



--- Comment #5 from Don <clugdbug@yahoo.com.au> 2012-03-21 12:51:44 PDT ---
*** Issue 6262 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 24, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6661



--- Comment #6 from github-bugzilla@puremagic.com 2013-01-24 14:27:48 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/e9142862884625d0db801bbf1f05ad9487aae28b fix test result for issue 6661

Inherently, when you try to instantiate a template, the whole template body correctness should be checked at the same time.

In this case, bug6661!(int).qutz is a normal function declared inside
template, so it should be instantiated at the same time with bug6661!(int).
Now, the inner `static assert(qutz(13).sizeof!=299);` runs the semantic3
of qutz by calling it. So the module level static assertion fails _correctly_.

But, `is(typeof(bug6661x!(int)))` still returns true incorrectly.
I think it is yet another known issue in current dmd implementation.

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