Bug 20945 – alias x = ref y compiles

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-06-17T23:03:02Z
Last change time
2024-12-13T19:09:19Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
Stanislav Blinov
Moved to GitHub: dmd#19722 →

Comments

Comment #0 by stanislav.blinov — 2020-06-17T23:03:02Z
alias refInt = ref int; // compiles alias outInt = out int; // does not Neither should.
Comment #1 by boris2.9 — 2020-06-18T04:58:47Z
There's one usage of this in Phobos even though it doesn't work. std/range/package.d ---------------------------- // This doesn't work yet static if (allSameType) { alias ElementType = ref RvalueElementType; } else { ----------------------------
Comment #2 by stanislav.blinov — 2020-06-18T10:10:52Z
...and that's been there since 2009 https://github.com/dlang/phobos/commit/e486c557bcb590b54bd414718c30c09fa6536e63 I'm almost tempted to make a PR that would add a "and never will" to that comment.
Comment #3 by stanislav.blinov — 2020-06-18T12:37:01Z
All of these compile: alias st = static int; alias au = auto int; alias sc = scope int; alias ov = override int; alias ab = abstract int; alias sy = synchronized int; alias nt = nothrow int; alias pu = pure int; alias re = ref int; And none of them should, ideally with a message such as: `ref` is not allowed in `alias` declaration. (Currently, `out` and `lazy` don't compile, but the message is not that succinct, as it falls through multiple parsing attemts).
Comment #4 by stanislav.blinov — 2020-06-18T13:53:25Z
...and then there's the whole old syntax of alias static int si; alias auto int au; alias scope int sc; alias override int ov; alias abstract int ab; alias synchronized int sy; alias nothrow int nt; alias pure int pu; alias ref int re; alias __gshared int gs;
Comment #5 by robert.schadek — 2024-12-13T19:09:19Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19722 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB