Annoying module name / typename conflict
Joakim via Digitalmars-d
digitalmars-d at puremagic.com
Sun Jul 16 02:55:30 PDT 2017
On Sunday, 16 July 2017 at 09:01:46 UTC, kdevel wrote:
> On Monday, 2 April 2012 at 22:20:13 UTC, bearophile wrote:
>
>> For DMD choosing one or the other is arbitrary. It's a defect
>> of the way the D module system is designed.
>
> Ran into that problem with a Module S containing
>
> module S;
> import std.stdio;
> struct S {
> this (string s)
> {
> writeln ("S: " ~ s);
> }
> }
>
> This code
>
> // auto s1 = S("X"); // useS.d(6): Error: function expected
> before (), not module S of type void
>
> would not compile while
>
> S s3 = "X"; // OK
>
> works. Has this issue been filed in bugzilla?
I hit this one recently and other variations before, a function
or local variable name clashing with a struct type name:
http://forum.dlang.org/thread/znjmmrdyghhtvypybwvc@forum.dlang.org
https://github.com/joakim-noah/android/commit/7e35c3ccd3a9d6ea870d39af44d9b11802c17a43
It probably generally has to do with keeping names unique in the
symbol namespace because of all the cool stuff you can do
interchangeably at compile-time, but I'm not sure how that
extends to module names too.
More information about the Digitalmars-d
mailing list