[Issue 23152] Bad diagnostic for variable used as a type

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jun 3 13:22:30 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=23152

RazvanN <razvan.nitu1305 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305 at gmail.com

--- Comment #1 from RazvanN <razvan.nitu1305 at gmail.com> ---
I, personally, find that the "is used as a type error" is actually misleading
in this context. S1 is a type, the problem is that the variable should have a
different name. The "circular reference to variable S1" is also annoying, but I
think it's closer to the truth since you are actually creating a circular
reference.

Ideally, the error message should be: "variable name S1 conflicts with struct
declaration S1". Also, it seems that:

void fun()
{
    S1 S1;
}

compiles just fine. Which should not.

--


More information about the Digitalmars-d-bugs mailing list