refInt = ref int: how to achieve this? or is this a bug?
Steven Schveighoffer
schveiguy at gmail.com
Thu Jun 18 14:16:51 UTC 2020
On 6/18/20 2:01 AM, mw wrote:
> 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 :-)
>
>
Three lines up:
https://github.com/dlang/phobos/blob/master/std/range/package.d#L918
// This doesn't work yet
I don't think it will ever work.
-Steve
More information about the Digitalmars-d
mailing list