www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Implicit cast rules of dynamic array

reply Erik Baklund <ebaklund hotmail.com> writes:
Hi,

Do anybody know if the implicit casting rules of float[] in the example below,
works as intended?

E.

--

// dmd v2.054
module main;

struct MyStruct
{
	void funOpAssign(float[1u] data) { }
	void opOpAssign(string op)(float[1u] data) if(op=="<<") { }
}

int main(string[] argv)
{
	MyStruct s;
	float[1u] a = [1.0f]; // Compiles
	s.funOpAssign([1.0f]); // Compiles
	s <<= [1.0f]; // Issue: Does not compile
	s <<= cast(float[1u])[1.0f]; // Compiles

	return 0;
}
Sep 03 2011
parent reply "Daniel Murphy" <yebblies nospamgmail.com> writes:
No, this is http://d.puremagic.com/issues/show_bug.cgi?id=4953

"Erik Baklund" <ebaklund hotmail.com> wrote in message 
news:j3u33n$1f87$1 digitalmars.com...
 Hi,

 Do anybody know if the implicit casting rules of float[] in the example 
 below,
 works as intended?

 E.

 --

 // dmd v2.054
 module main;

 struct MyStruct
 {
 void funOpAssign(float[1u] data) { }
 void opOpAssign(string op)(float[1u] data) if(op=="<<") { }
 }

 int main(string[] argv)
 {
 MyStruct s;
 float[1u] a = [1.0f]; // Compiles
 s.funOpAssign([1.0f]); // Compiles
 s <<= [1.0f]; // Issue: Does not compile
 s <<= cast(float[1u])[1.0f]; // Compiles

 return 0;
 } 

Sep 03 2011
parent reply Erik Baklund <ebaklund hotmail.com> writes:
Thanks!
Ouch, the regression is still not fixed after almost one year.
I have put a vote on it.
E.
Sep 04 2011
parent "Daniel Murphy" <yebblies nospamgmail.com> writes:
The good news is there are two possible patches that should fix it.

"Erik Baklund" <ebaklund hotmail.com> wrote in message 
news:j3v9dk$ero$1 digitalmars.com...
 Thanks!
 Ouch, the regression is still not fixed after almost one year.
 I have put a vote on it.
 E. 

Sep 04 2011