Discussion Thread: DIP 1044--Enum Type Inference--Community Review Round 1

Walter Bright newshound2 at digitalmars.com
Tue Nov 22 18:16:43 UTC 2022


On 11/21/2022 5:41 PM, Timon Gehr wrote:
> On 22.11.22 01:49, Walter Bright wrote:
>> On 11/20/2022 1:58 PM, Timon Gehr wrote:
>>> On 20.11.22 22:32, Walter Bright wrote:
>>>>
>>>> But yes, it would be a (small) breaking change.
>>>
>>> I really wouldn't want to run into this:
>>>
>>> ```d
>>> enum Role{
>>>      guest,
>>>      member,
>>>      developer,
>>> }
>>>
>>> void main(){
>>>      Role r;
>>>      writeln(r); // error
> (Should perhaps be auto s = to!string(r);)
>>> }
>>> ```
>>>
>>> Too messy for me, but up to you.
>>
>> I'm not seeing where the shadowing is?
> 
> That's indeed basically the point. It's invisible.

This code:

---
import std.stdio;

enum Role{
      guest,
      member,
      developer,
}

void main(){
      Role r;
      writeln(r); // error
}
---

compiles successfully and when run prints:

guest



More information about the Digitalmars-d mailing list