refInt = ref int: how to achieve this? or is this a bug?
mw
mingwu at gmail.com
Wed Jun 17 23:24:32 UTC 2020
On Wednesday, 17 June 2020 at 23:09:55 UTC, Stanislav Blinov
wrote:
>> 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
Given the current language semantics, right, it shouldn't be
typedef/alias-ed,
But it make the code so complex / ugly to write:
either:
void foo(T)(auto ref T v) if (is(T : int) == __traits(isRef, v))
{}
or
f( T) /*more static if here*/ { /*potential dup code here*/ }
f(ref T) /*more static if here*/ { /*potential dup code here*/ }
I would call for improvement.
> the compiler, for not issuing an error.
>
> [1] https://dlang.org/spec/const3.html
More information about the Digitalmars-d
mailing list