www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Semantic change from 2.078.3 to 2.079.0

reply =?UTF-8?B?TcOhcmNpbw==?= Martins <marcioapm gmail.com> writes:
Hi, recently we tried to upgrade DMD from 2.078.3 to 2.080 and 
found an unexpected semantic change.

Consider this program:

import std.traits;
enum X { Y = "z" };
alias T = typeof(X.Y);

pragma(msg, is(T == enum));
pragma(msg, isSomeString!T);
void main() {}`

Output in DMD <= 2.078.3:
true
true

Output in DMD >= 2.079.0:
true
false

This silent change is really nasty, and causing all sorts of 
breakages.
Was this a bug-fix, and if so, should we expect the new behavior 
to stick?
May 23 2018
parent reply ag0aep6g <anonymous example.com> writes:
On 05/23/2018 11:21 AM, Márcio Martins wrote:
 Hi, recently we tried to upgrade DMD from 2.078.3 to 2.080 and found an 
 unexpected semantic change.
 
 Consider this program:
 
 import std.traits;
 enum X { Y = "z" };
 alias T = typeof(X.Y);
 
 pragma(msg, is(T == enum));
 pragma(msg, isSomeString!T);
 void main() {}`
 
 Output in DMD <= 2.078.3:
 true
 true
 
 Output in DMD >= 2.079.0:
 true
 false
 
 This silent change is really nasty, and causing all sorts of breakages.
 Was this a bug-fix, and if so, should we expect the new behavior to stick?
In the changelog: https://dlang.org/changelog/2.079.0.html#std-traits-issomestring
May 23 2018
parent reply =?UTF-8?B?TcOhcmNpbw==?= Martins <marcioapm gmail.com> writes:
On Wednesday, 23 May 2018 at 09:26:48 UTC, ag0aep6g wrote:
 On 05/23/2018 11:21 AM, Márcio Martins wrote:
 Hi, recently we tried to upgrade DMD from 2.078.3 to 2.080 and 
 found an unexpected semantic change.
 
 Consider this program:
 
 import std.traits;
 enum X { Y = "z" };
 alias T = typeof(X.Y);
 
 pragma(msg, is(T == enum));
 pragma(msg, isSomeString!T);
 void main() {}`
 
 Output in DMD <= 2.078.3:
 true
 true
 
 Output in DMD >= 2.079.0:
 true
 false
 
 This silent change is really nasty, and causing all sorts of 
 breakages.
 Was this a bug-fix, and if so, should we expect the new 
 behavior to stick?
In the changelog: https://dlang.org/changelog/2.079.0.html#std-traits-issomestring
Wow! I don't know I missed it! I would expect something like this to go through the deprecation process as it effectively silently breaks a ton of code.
May 23 2018
parent reply Jonathan M Davis <newsgroup.d jmdavisprog.com> writes:
On Wednesday, May 23, 2018 09:31:35 Márcio Martins via Digitalmars-d wrote:
 On Wednesday, 23 May 2018 at 09:26:48 UTC, ag0aep6g wrote:
 On 05/23/2018 11:21 AM, Márcio Martins wrote:
 Hi, recently we tried to upgrade DMD from 2.078.3 to 2.080 and
 found an unexpected semantic change.

 Consider this program:

 import std.traits;
 enum X { Y = "z" };
 alias T = typeof(X.Y);

 pragma(msg, is(T == enum));
 pragma(msg, isSomeString!T);
 void main() {}`

 Output in DMD <= 2.078.3:
 true
 true

 Output in DMD >= 2.079.0:
 true
 false

 This silent change is really nasty, and causing all sorts of
 breakages.
 Was this a bug-fix, and if so, should we expect the new
 behavior to stick?
In the changelog: https://dlang.org/changelog/2.079.0.html#std-traits-issomestring
Wow! I don't know I missed it! I would expect something like this to go through the deprecation process as it effectively silently breaks a ton of code.
It would have, but there is literally no way to put it through the deprecation process without deprecating isSomeString and replacing it with something else, which would have broken tons of code. There is no way to just deprecate the behavior. It was determined that it was unlikely that much code would break and that it would in turn fix quite a bit of code and prevent further bugs that the old behavior encouraged. And in general, the fixes should be easy, since in most cases, it results in a compilation error and then a quick fix to a template constraint or static if to get the old behavior back if it was indeed intentional and not a bug. We would like to have handled it better, but there really wasn't a better way given the options. - Jonathan M Davis
May 23 2018
parent reply =?UTF-8?B?TcOhcmNpbw==?= Martins <marcioapm gmail.com> writes:
On Wednesday, 23 May 2018 at 09:43:28 UTC, Jonathan M Davis wrote:
 [...]
Got it! Thanks!
May 23 2018
parent Steven Schveighoffer <schveiguy yahoo.com> writes:
On 5/23/18 11:31 AM, Márcio Martins wrote:
 On Wednesday, 23 May 2018 at 09:43:28 UTC, Jonathan M Davis wrote:
 [...]
Got it! Thanks!
Note, you could create an isSomeStringOrEnum template that does the old behavior, and just do a sed 's/isSomeString!/isSomeStringOrEnum!/g' -Steve
May 23 2018