Thread overview
[Issue 13995] Alias type stringof decay to alias type stringof
Jan 17, 2015
Walter Bright
Jan 17, 2015
deadalnix
Jan 17, 2015
deadalnix
Jan 18, 2015
Jonathan M Davis
Jan 18, 2015
deadalnix
Jan 18, 2015
Marc Schütz
Jan 19, 2015
Dicebot
Dec 17, 2022
Iain Buclaw
January 17, 2015
https://issues.dlang.org/show_bug.cgi?id=13995

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> ---
Please have a compilable example.

--
January 17, 2015
https://issues.dlang.org/show_bug.cgi?id=13995

--- Comment #2 from deadalnix <deadalnix@gmail.com> ---
(In reply to Walter Bright from comment #1)
> Please have a compilable example.

alias T = int;

void main() {
  writeln(T.stringof);
}

Here you go. This should print T, not int.

--
January 17, 2015
https://issues.dlang.org/show_bug.cgi?id=13995

--- Comment #3 from deadalnix <deadalnix@gmail.com> ---
Alternatively :

enum StringOf(T) = T.stringof;

void main() {
  writeln(StringOf!uint);
}

This should also print T.

--
January 18, 2015
https://issues.dlang.org/show_bug.cgi?id=13995

Jonathan M Davis <issues.dlang@jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dlang@jmdavisProg.co
                   |                            |m

--- Comment #4 from Jonathan M Davis <issues.dlang@jmdavisProg.com> ---
While I can certainly see why you'd want this (and it may very well be that we should make the change), I would point out that aliases _always_ disappear when they're used. I'm not aware of anywhere that the compiler treats the alias as anything other than the original to the point that it just about might as well be searching and replacing the alias with the original symbol in the text of the program. The alias never shows up in any error messages. So, having it show up with stringof would be a pretty major change with regards to how aliases are treated (be that for better or for worse).

As for this specific problem, I would point out that your initial example doesn't use aliases at all, so it doesn't show how the current behavior of stringof on an alias would actually cause compilation problems, and your follow up examples just show how stringof on an alias prints the original symbol rather than the alias name. They don't show how that actually causes problems.

So, as a follow up to what Walter requested, I'd ask that you provide an example that would compile if stringof on an alias gave the alias name rather than the original symbol name and which does not compile with the current behavior. So, it shows what you're actually trying to do but isn't working right now. As it stands, I don't understand what you're trying to do well enough to unnderstand why the current behavior is causing a problem, and I suspect that Walter is in the same boat.

--
January 18, 2015
https://issues.dlang.org/show_bug.cgi?id=13995

--- Comment #5 from deadalnix <deadalnix@gmail.com> ---
Johnatan, I made the sample code short so the problematic behavior can be demonstrated. I tried to explain where it causes problem, but apparently, I haven't been clear enough, so let me expand myself on the subject.

Consider the sample code :

module a;

struct S(E) {
    import std.bitmanip;
    mixin(bitfield!(
        E, "e", 10,
        uint, "", 6,
    ));
}

module b;

enum A { A, B }

import a;

S!A s;

There is absolutely no way to make that work (even when modifying bitfield) given the current behavior of stringof.

--
January 18, 2015
https://issues.dlang.org/show_bug.cgi?id=13995

Marc Schütz <schuetzm@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schuetzm@gmx.net

--- Comment #6 from Marc Schütz <schuetzm@gmx.net> ---
If this is implemented, care must be taken to keep the behaviour of `__traits(identifier, ...)` as it is. vibe.d uses it to make local variables, passed as aliases, accessible inside the template by their name:

http://vibed.org/api/vibe.http.server/render https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/templ/utils.d#L104

--
January 19, 2015
https://issues.dlang.org/show_bug.cgi?id=13995

Dicebot <public@dicebot.lv> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |public@dicebot.lv

--- Comment #7 from Dicebot <public@dicebot.lv> ---
Chaging this will break huge amount of template code. I have personally written many snipppets that rely on the fact that template arguments resolve to underlying symbols. Actually, if this stops working, it will be rather hard to implement thing like `stringify!int == "int"` because __traits(identifier) works only on symbols.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=13995

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--
December 13
https://issues.dlang.org/show_bug.cgi?id=13995

--- Comment #8 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18928

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--