Thread overview
[Issue 8002] New: Excess initial errors when passing template args to non-templated struct
Apr 29, 2012
Nick Sabalausky
Apr 30, 2012
Kenji Hara
Apr 30, 2012
Walter Bright
April 29, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8002

           Summary: Excess initial errors when passing template args to
                    non-templated struct
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: cbkbbejeap@mailinator.com


--- Comment #0 from Nick Sabalausky <cbkbbejeap@mailinator.com> 2012-04-29 14:14:11 PDT ---
---------------
import std.stdio;

struct Foo
{
    int a;
}

int bar()
{
    writeln();
    return 1;
}

void main()
{
    Foo x = Foo!(bar());
}
---------------

A template argument is (accidentally) being passed to Foo. The compiler should, and does, print a "not a template declaration" error. But before doing so, it evaluates the completely erroneous template arg, resulting in a big pile of totally non-applicable error text ("cannot be interpreted at compile time") which obscures the one real problem.

>dmd test.d
C:\Documents and Settings\Nick Sabalausky\Application
Data\dvm\compilers\dmd-2.059\bin\..\src\phobos\std\stdio.d(1548): Error: fputc
cannot be interpreted at compile time, because it has no available source code
C:\Documents and Settings\Nick Sabalausky\Application
Data\dvm\compilers\dmd-2.059\bin\..\src\phobos\std\stdio.d(1548):        called
from here: enforce(fputc(10,(*stdout.p).handle) == 10,delegate pure nothrow
@safe const(char)[]()
{
return null;
}
)
test.d(10):        called from here: writeln()
test.d(16):        called from here: bar()
test.d(16): Error: template instance Foo!(bar()) Foo is not a template
declaration, it is a struct

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-04-30 08:05:07 PDT ---
https://github.com/D-Programming-Language/dmd/pull/915

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



--- Comment #2 from github-bugzilla@puremagic.com 2012-04-30 11:22:17 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/81eca37fcb551a9adbec23f9d60c6b1fc90e247d
fix Issue 8002 - Excess initial errors when passing template args to
non-templated struct

https://github.com/D-Programming-Language/dmd/commit/d303d30500689dc4f9c9b60ae4b497549887c2b4 Merge pull request #915 from 9rnsr/fix8002

Issue 8002 - Excess initial errors when passing template args to non-templated struct

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


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


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