www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4285] New: template inside function error message

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

           Summary: template inside function error message
           Product: D
           Version: future
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2010-06-06 06:53:06 PDT ---
This is wrong D2 program:

void main() {
    template Foo {}
}


DMD v2.046 prints at compile-time:

test.d(2): found 'template' instead of statement
test.d(3): unrecognized declaration


But a better and more readable error message can be:

test.d(2): Error: template definitions aren't allowed inside functions.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 06 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4285



--- Comment #1 from bearophile_hugs eml.cc 2010-06-06 07:24:00 PDT ---
A similar error message can be used for imports too inside functions.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 06 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4285



--- Comment #2 from Ellery Newcomer <ellery-newcomer utulsa.edu> 2010-06-06
08:22:55 PDT ---
Created an attachment (id=657)
error messages!

good ideas.

note this patch also enables import expressions at statement level, which
wasn't previously allowed. it yields a better error message this way (I think).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 06 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4285



--- Comment #3 from bearophile_hugs eml.cc 2010-06-06 08:38:02 PDT ---
Thank you Ellery :-)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 06 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4285


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|patch                       |pull
                 CC|                            |yebblies gmail.com
           Platform|Other                       |All
         OS/Version|Windows                     |All


--- Comment #4 from yebblies <yebblies gmail.com> 2012-10-27 21:56:26 EST ---
Fixed D2

https://github.com/D-Programming-Language/dmd/pull/1198

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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 27 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4285



--- Comment #5 from bearophile_hugs eml.cc 2012-10-27 04:49:59 PDT ---
Templated functions are allowed inside functions:

void main() {
    T foo(T)(T x) {
        return x * x;
    }
    assert(foo(10) == 100);
    assert(foo(10L) == 100L);
}


So why are templates not accepted inside functions? It's a handy "all the
turtles down" as Walter says.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 27 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4285



--- Comment #6 from yebblies <yebblies gmail.com> 2012-10-27 22:54:06 EST ---
(In reply to comment #5)
 Templated functions are allowed inside functions:
 
 So why are templates not accepted inside functions? It's a handy "all the
 turtles down" as Walter says.
That would be "turtles all the way down". I agree, but this bug report is about the poor error message. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 27 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4285


bearophile_hugs eml.cc changed:

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


--- Comment #7 from bearophile_hugs eml.cc 2012-10-27 06:13:57 PDT ---
(In reply to comment #6)

 I agree, but this bug report is about the poor error message.
Sure. Closed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 27 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4285


yebblies <yebblies gmail.com> changed:

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


--- Comment #8 from yebblies <yebblies gmail.com> 2012-10-28 00:15:06 EST ---
This bug still exists for D1.

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