Thread overview
[Issue 17404] creating type named 'object' fails to compile, but only if you import something
May 17, 2017
Ketmar Dark
May 17, 2017
Ketmar Dark
May 17, 2017
Vladimir Panteleev
Nov 18, 2022
RazvanN
May 17, 2017
https://issues.dlang.org/show_bug.cgi?id=17404

--- Comment #1 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
this is how the compiler works: when you import *something*, it implicitly imports module "object.d" (see druntime). this is core module that contains all the basic things.

the reason D doesn't do it when there are no imports is simple: do allow compiling object.d itself.

it is really hard to fix this error message without writing a wall of text explaining what is going on. sure, error message can be better, but it still should be concise, to not annoy expirienced users. if you can think out something good, please, make a PR (or just write it here). anything that will make error messages better is welcome! ;-)

--
May 17, 2017
https://issues.dlang.org/show_bug.cgi?id=17404

Ketmar Dark <ketmar@ketmar.no-ip.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ketmar@ketmar.no-ip.org

--
May 17, 2017
https://issues.dlang.org/show_bug.cgi?id=17404

Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, diagnostic
                 CC|                            |thecybershadow@gmail.com
           Hardware|x86                         |All
                 OS|Windows                     |All

--
November 18, 2022
https://issues.dlang.org/show_bug.cgi?id=17404

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |razvan.nitu1305@gmail.com
         Resolution|---                         |WONTFIX

--- Comment #2 from RazvanN <razvan.nitu1305@gmail.com> ---
This now outputs:

test.d(1): Error: struct `test.object` conflicts with import `test.object` at
test.d

regardless if you have any imports or not.

I think we can close this as WONTFIX, because the compiler automatically imports object.d (except if you compile with -betterC) so I don't see how the error message could be improved without adding a measly special case in the compiler.

--