refInt = ref int: how to achieve this? or is this a bug?

mw mingwu at gmail.com
Thu Jun 18 06:01:52 UTC 2020


On Wednesday, 17 June 2020 at 23:09:55 UTC, Stanislav Blinov 
wrote:
> On Wednesday, 17 June 2020 at 23:05:59 UTC, mw wrote:
>> On Wednesday, 17 June 2020 at 22:48:25 UTC, MoonlightSentinel 
>> wrote:
>>> But i would agree with you that there is a bug in your initial
>>
>> It's not the bug in my code,
>>
>>> code, the `ref` should be rejected.
>>
>> it's the compiler's bug not rejecting it, given it's current 
>> semantics; instead it *silently* treat alias `ref int` as 
>> `int`.
>
> It is both. In your code, for trying to use `ref` as a type 
> qualifier when it is not (see [1] for type qualifiers), and in 
> the compiler, for not issuing an error.
>
> [1] https://dlang.org/spec/const3.html


https://github.com/dlang/phobos/blob/master/std/range/package.d#L921
```
                 alias ElementType = ref RvalueElementType;
```

Even code in phobos try to write this way too :-)




More information about the Digitalmars-d mailing list