Re: Bug or expected?

2019-01-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/8/19 3:12 PM, SrMordred wrote: size_t[2] a; size_t[2] b; auto x  = a[] & b[]; //array operation without destination memory not allowed size_t[2] y = a[] & b[]; // fine Honestly, I wouldn't have expected either to work. My understanding was that array operations require slicing on

Bug or expected?

2019-01-08 Thread SrMordred via Digitalmars-d-learn
size_t[2] a; size_t[2] b; auto x = a[] & b[]; //array operation without destination memory not allowed size_t[2] y = a[] & b[]; // fine

Re: Constructor qualifiers; bug or expected behavior?

2018-04-02 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Apr 02, 2018 at 10:26:32AM +, RazvanN via Digitalmars-d-learn wrote: > Hi all, > > Let's say we have this code: > > struct B > { > int a; > this(int a) immutable > { > this.a = 7; > } > > this(int a) > { > this.a = 10; > } > } > > void

Re: Constructor qualifiers; bug or expected behavior?

2018-04-02 Thread Seb via Digitalmars-d-learn
On Monday, 2 April 2018 at 11:41:55 UTC, Eduard Staniloiu wrote: On Monday, 2 April 2018 at 10:26:32 UTC, RazvanN wrote: [...] The compiler does an implicit conversion from the type `immutable B` to the type `B`. It is able to do safely do so because `struct B` has only value types that

Re: Constructor qualifiers; bug or expected behavior?

2018-04-02 Thread Eduard Staniloiu via Digitalmars-d-learn
On Monday, 2 April 2018 at 10:26:32 UTC, RazvanN wrote: Hi all, Let's say we have this code: struct B { int a; this(int a) immutable { this.a = 7; } this(int a) { this.a = 10; } } void main() { B a = immutable B(2); writeln(a.a); a.a =

Constructor qualifiers; bug or expected behavior?

2018-04-02 Thread RazvanN via Digitalmars-d-learn
Hi all, Let's say we have this code: struct B { int a; this(int a) immutable { this.a = 7; } this(int a) { this.a = 10; } } void main() { B a = immutable B(2); writeln(a.a); a.a = 4; immutable B a2 = immutable B(3);