new error message in 2.066, type bool (const)
Re-compiling existing code with version 2.066 generates a lot of errors complaining about implicit conversion to const. Typical is this call (inside a struct with properties 1 & 2): z.sign = x.sign ^ y.sign; Error: None of the overloads of 'sign' are callable using argument types bool (const), candidates are: 1) @property @safe bool sign() const { return signed; } 2) @property @safe bool sign(in bool value) { signed = value; return signed; } What changed? It ran okay with early beta versions, but not with the release. Paul
Re: new error message in 2.066, type bool (const)
On Wednesday, 20 August 2014 at 20:46:20 UTC, Paul D Anderson wrote: Re-compiling existing code with version 2.066 generates a lot of errors complaining about implicit conversion to const. Typical is this call (inside a struct with properties 1 & 2): z.sign = x.sign ^ y.sign; Error: None of the overloads of 'sign' are callable using argument types bool (const), candidates are: 1) @property @safe bool sign() const { return signed; } 2) @property @safe bool sign(in bool value) { signed = value; return signed; } What changed? It ran okay with early beta versions, but not with the release. Paul Could you provide a short, but complete program that reproduces the issue? With this: // struct S { bool signed; @property @safe bool sign() const { return signed; } @property @safe bool sign(in bool value) { signed = value; return signed; } } void main(string[] args) { S s; s.sign = s.sign ^ s.sign; } // It works for me with both 2.065.0 and 2.066.0. What is the type of "signed" ? Is it something other than bool, by any chance?
Re: new error message in 2.066, type bool (const)
What changed? It ran okay with early beta versions, but not with the release. Paul It compiles in beta-5 but not beta-6. Is the list of changes in the beta testing wiki complete? None seem pertinent. monarch_dodra: Thanks for checking. I was trying to avoid tearing everything down. I was hoping someone would recognize the error. Looks like I'll have to chase it down. Paul
Re: new error message in 2.066, type bool (const)
On Thursday, 21 August 2014 at 03:02:53 UTC, Paul D Anderson wrote: What changed? It ran okay with early beta versions, but not with the release. Paul It compiles in beta-5 but not beta-6. Is the list of changes in the beta testing wiki complete? None seem pertinent. monarch_dodra: Thanks for checking. I was trying to avoid tearing everything down. I was hoping someone would recognize the error. Looks like I'll have to chase it down. Paul https://github.com/CyberShadow/digger should be able to help find the exact commit. A reduced example would help us figure out what is going on though.
Re: new error message in 2.066, type bool (const)
On Wednesday, 20 August 2014 at 20:46:20 UTC, Paul D Anderson wrote: Re-compiling existing code with version 2.066 generates a lot of errors complaining about implicit conversion to const. Typical is this call (inside a struct with properties 1 & 2): z.sign = x.sign ^ y.sign; Error: None of the overloads of 'sign' are callable using argument types bool (const), candidates are: 1) @property @safe bool sign() const { return signed; } 2) @property @safe bool sign(in bool value) { signed = value; return signed; } What changed? It ran okay with early beta versions, but not with the release. Paul The problem (not obvious from the above) is that a templated type is bringing its qualifiers into the template. Here is a small example: T add(T)(in T x, in T y) { T z; z = x + y; return z; } void main() { const double a = 1.0; const double b = 2.0; double c; c = add(a,b); } Error: Cannot modify immutable expression z --- Since a and b are const double the deduced template type is also const double. Then when z is declared as type T it is also const. This compiled and ran in beta 5 but not in beta 6. If I modify the above so that declaration and assignment are performed at the same time: T z = x + y; This compiles and assigns the (const double) value 3.0 to z. After the function call c contains the double value 3.0, but it is no longer const. The error can be avoided by declaring z to be of type Unqual!T in most cases. I don't know if this is expected behavior that just wasn't enforced before, or if this is something new. Either way I don't like it. And I'm a little surprised I'm the only one affected by this. I'll keep digging. Paul
Re: new error message in 2.066, type bool (const)
On Friday, 22 August 2014 at 01:25:05 UTC, Paul D Anderson wrote: On Wednesday, 20 August 2014 at 20:46:20 UTC, Paul D Anderson I don't know if this is expected behavior that just wasn't enforced before, or if this is something new. Either way I don't like it. And I'm a little surprised I'm the only one affected by this. I'll keep digging. Paul https://issues.dlang.org/show_bug.cgi?id=13351