When using old alias form, `ref` is both accepted and not making any effect: ----------- alias ref int RefInt; void foo(RefInt x) { x = 42; } void main() { int x; foo(x); import std.stdio : writeln; writeln(x); } ----------- 0 ----------- `alias RefInt = ref int` is rejected with "Error: basic type expected, not ref" so I assume it should be the same here.
More nonsense: alias ref int ri; //alias in int ii; alias int oi; //alias lazy int li; //alias out int outi; alias pure int pi; alias @safe int si; //alias trusted int ti; alias nothrow int nthi; alias auto int ai; alias @property int pri; alias @disable int di; alias scope int sci; alias align(16) int ali; alias abstract int absi; alias final int fi; alias override int ovi; alias inout int inoui; alias synchronized int syi; alias static int stati; It is unclear however, whether this is a part of major accepts-invalid bug (dmd is permissive in allowing to apply attributes to declarations, so here is particular case) or defficiency in old alias syntax parsing.
Whatever it is, current behavior is extremely confusing for newbies as one may expect it to actually work in example like provided in the first post.
See also Issue 3934
*** Issue 12299 has been marked as a duplicate of this issue. ***
*** Issue 12257 has been marked as a duplicate of this issue. ***
phobos PR https://github.com/D-Programming-Language/phobos/pull/2995 is sort of blocked by: template RefType(T) alias RefType = ref T; not working anymore
The grammar allows this to make alias RefDG = ref int delegate(); legal. Having ref be accepted but with no effect is nothing special about the D compiler. It accepts a lot of annotations that have no effect. The question which cases are accepts-invalid and which are not is mostly a matter of taste.
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18724 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB