www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - [dmd2.068] Bug or future?

reply "VlasovRoman" <vlasovroman.ru yandex.ru> writes:
I have some code:

import std.stdio;

auto dot(T, R)(T x, R y) {
     return x * y;
}

struct Vector(T)
{
     alias selftype = Vector!T;
     int len = 5;
pure:
     const  property{
         static if( is( typeof( dot( selftype.init, selftype.init 
) ) ) ){
             auto len2() {return len * len;}
     	}

	static if(is(typeof(T.init * T.init) == T)) {
		auto e() {return len;}
	}
     }
}


void main() {
     Vector!(float) vec;
     float x = vec.len2();
     writeln(x);
     x = vec.e();
     writeln(x);
}

I get error by compiler when i build this:
main.d(30): Error: no property 'len2' for type 'Vector!float', 
did you mean 'len'?

In dmd 2.067 is normaly.
is it Bug or enhancements?
Aug 06 2015
next sibling parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 08/06/2015 11:26 PM, VlasovRoman wrote:

 I have some code:
Reduced: import std.stdio; auto foo(T)(T) { return 42; } struct Vector(T) { pragma(msg, is(typeof(foo(Vector.init)))); // prints true static if(is(typeof(foo(Vector.init)))) { static assert(false); // is not included } } void main() { Vector!float v; } 'static if' fails to include code even though the is expression produces 'true'. I think this is a regression. If others agree let's create a regression quickly before tomorrow's (today's?) planned release. Ali
Aug 06 2015
prev sibling next sibling parent "Daniel Kozak" <kozzi11 gmail.com> writes:
On Friday, 7 August 2015 at 06:26:21 UTC, VlasovRoman wrote:
 I have some code:

 import std.stdio;

 auto dot(T, R)(T x, R y) {
     return x * y;
 }

 struct Vector(T)
 {
     alias selftype = Vector!T;
     int len = 5;
 pure:
     const  property{
         static if( is( typeof( dot( selftype.init, 
 selftype.init ) ) ) ){
             auto len2() {return len * len;}
     	}

 	static if(is(typeof(T.init * T.init) == T)) {
 		auto e() {return len;}
 	}
     }
 }


 void main() {
     Vector!(float) vec;
     float x = vec.len2();
     writeln(x);
     x = vec.e();
     writeln(x);
 }

 I get error by compiler when i build this:
 main.d(30): Error: no property 'len2' for type 'Vector!float', 
 did you mean 'len'?

 In dmd 2.067 is normaly.
 is it Bug or enhancements?
Does not work in 2.067 for me. Btw. you do not need to do this: alias selftype = Vector!T; You can just use Vector, or: alias selftype = Vector; if you prefer selftype as a name.
Aug 07 2015
prev sibling parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 08/06/2015 11:26 PM, VlasovRoman wrote:
 I have some code:
Filed: https://issues.dlang.org/show_bug.cgi?id=14883 Ali
Aug 07 2015