[Issue 5686] class template error

2011-03-03 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5686



--- Comment #1 from changlon chang...@gmail.com 2011-03-03 00:27:11 PST ---
update test case:
-
class Test2(string name,  string file = __FILE__, ptrdiff_t line = __LINE__){
static assert( line != __LINE__ -1 );

ptrdiff_t test( string file = __FILE__, ptrdiff_t line = __LINE__)(){
static assert( line != __LINE__ -1 );
return line ;
}
}

void main(){
auto test2 = new Test2!(test) ;
test2.test ;
}
---

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


[Issue 5686] class template error

2011-03-03 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5686


Steven Schveighoffer schvei...@yahoo.com changed:

   What|Removed |Added

 CC||schvei...@yahoo.com


--- Comment #3 from Steven Schveighoffer schvei...@yahoo.com 2011-03-03 
06:36:13 PST ---
(In reply to comment #2)
 In the static assert line (line 8), __LINE__ should be 8, and line should be 
 7,
 since the previous line contains the declaration of line.

Wow, that was confusing :)  Let's call the template parameter lineno.  I'll try
again:

In the static assert line (line 8), __LINE__ should be 8, and lineno should be
7,
since the previous line contains the declaration of lineno.

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


[Issue 5686] class template error

2011-03-03 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5686



--- Comment #4 from changlon chang...@gmail.com 2011-03-03 06:45:53 PST ---
The lineno shoule be the lineno where template is be instantiated, not where it
be declared .

for template and function template it is  working . for class template and
class member template it is not working .

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


[Issue 5686] class template error

2011-03-03 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5686



--- Comment #5 from changlon chang...@gmail.com 2011-03-03 06:50:13 PST ---
---
ptrdiff_t Test1( string file = __FILE__, ptrdiff_t line = __LINE__)(){
pragma(msg, line.stringof);
return line ;
}

class Test2(string name,  string file = __FILE__, ptrdiff_t line = __LINE__){
pragma(msg, line.stringof);
}
void main(){
auto test1 = Test1();
auto test2 = new Test2!(test) ;
}
---
compile this the dmd print 11, 7. dmd should print 11, 12 .

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


[Issue 5686] class template error

2011-03-03 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5686



--- Comment #6 from Steven Schveighoffer schvei...@yahoo.com 2011-03-03 
07:16:34 PST ---
With some testing, I discovered that it's the act of explicit instantiation
that causes the line number to be tied to the declaration line:

ptrdiff_t Test1(string name, string file = __FILE__, ptrdiff_t line =
__LINE__)(){
pragma(msg, line.stringof);
return line ;
}

void main(){
auto test1 = Test1!(test)();
}

prints 1.

This workaround does work:

Test2!(file, line) createTest2(string file = __FILE__, ptrdiff_t line =
__LINE__)()
{
   return new Test2!(file line);
}

I agree with the request that the line number and file should be tied to the
instantiation line, not the declaration line.

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