www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2257] New: Template value parameters behave like alias parameters

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

           Summary: Template value parameters behave like alias parameters
           Product: D
           Version: 2.017
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: samukha voliacable.com


import std.stdio;

template Foo(string s)
{
  enum Foo = s; // changing enum to invariant fixes the issue.
}

void main()
{
  string a = "str";
  alias Foo!(a) b; // b is now an alias of a. Should be a compiler error
}


-- 
Jul 31 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2257





------- Comment #1 from samukha voliacable.com  2008-10-13 00:32 -------
"compiler error" in the example was meant to be "compile error"


-- 
Oct 12 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2257


Rob Jacques <sandford jhu.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sandford jhu.edu


--- Comment #2 from Rob Jacques <sandford jhu.edu> 2009-10-13 10:21:10 PDT ---
This issue causes major issues with Nd-array and Small Vector implementations,
as the incorrect type signatures play havoc with other templated functions.
Here is another test case illustrating the problem:

import std.stdio;
struct Matrix(T,size_t D) {
    Matrix!(U,D) foo(U)(U v) { return Matrix!(U,D)(); }
}

void main() {
    real r;
    size_t d = 2;
    Matrix!(float,2) m;
    writeln(typeof( m.foo(r) ).stringof);            //writes Matrix(float,D)
    Matrix!(float,d) n;
    writeln(typeof( n ).stringof);                   //writes Matrix(float,d)
}

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



--- Comment #3 from Rob Jacques <sandford jhu.edu> 2009-11-06 22:23:35 PST ---
(In reply to comment #2)
 This issue causes major issues with Nd-array and Small Vector implementations,
 as the incorrect type signatures play havoc with other templated functions.
 Here is another test case illustrating the problem:
 
 import std.stdio;
 struct Matrix(T,size_t D) {
     Matrix!(U,D) foo(U)(U v) { return Matrix!(U,D)(); }
 }
 
 void main() {
     real r;
     size_t d = 2;
     Matrix!(float,2) m;
     writeln(typeof( m.foo(r) ).stringof);            //writes Matrix(float,D)
     Matrix!(float,d) n;
     writeln(typeof( n ).stringof);                   //writes Matrix(float,d)
 }

A Mitigation for the above example: Matrix!(U,D+0) foo(U)(U v) { return Matrix!(U,D)(); } changes "Matrix(float,D)" to "writes Matrix(float,2u)" However, the original template type is still distinct: Matrix(float,2) Also, it appears that even though D is unsigned, the template type is signed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 06 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2257


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc


--- Comment #4 from Don <clugdbug yahoo.com.au> 2010-12-01 02:29:17 PST ---
*** Issue 4289 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: -------
Dec 01 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2257


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au


--- Comment #5 from Don <clugdbug yahoo.com.au> 2010-12-01 02:29:56 PST ---
Bug 2550 has the same root cause, I think.

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