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



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




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




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




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



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




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





 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





 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                       |



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