www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9934] New: template default argument should be semantically analysed

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

           Summary: template default argument should be semantically
                    analysed
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: code dawg.eu



cat > bug.d << CODE
template foo(T = NonExistent)
{
}
CODE

dmd -c bug

----

This currently compiles even though the default parameter can never be valid.
When the default parameter is a template instance it is missing from the object
file. I think we should run full semantics on the default arguments when
compiling a module.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 14 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9934


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



02:05:23 PDT ---
What if the template is in a mixin template? Or would the change not affect
this?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 15 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9934





 What if the template is in a mixin template? Or would the change not affect
 this?
Even if the template is used for mixin, default template arguments are evaluated in declaration side. alias NonExistent = int; // [a] template foo(T = NonExistent) // [b] { pragma(msg, T); // prints 'int' } class C { alias NonExistent = string; mixin foo; } If you comment out line [a], compiler reports "Error: undefined identifier NonExistent" in line [b]. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 15 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9934




03:08:18 PDT ---


 What if the template is in a mixin template? Or would the change not affect
 this?
Even if the template is used for mixin, default template arguments are evaluated in declaration side.
Ok makes sense, I never tried it before. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 16 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9934


timon.gehr gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr gmx.ch
           Severity|normal                      |enhancement




 cat > bug.d << CODE
 template foo(T = NonExistent)
 {
 }
 CODE
 
 dmd -c bug
 
 ----
 
 This currently compiles even though the default parameter can never be valid.
 When the default parameter is a template instance it is missing from the object
 file. I think we should run full semantics on the default arguments when
 compiling a module.
This is not really clear. Default parameters can depend on other template arguments. Therefore, running full semantics is not possible. You'd have to specify clearly in what cases there is an error. However, I think it is not necessarily a good idea to add non-obvious rules about validity of a template declaration. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 16 2013