Annoying module name / typename conflict

Andre Pany via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 16 10:32:06 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?

You can avoid this issue at all by using lowercase characters in 
module name only. This is also the offical naming guideline for 
modules.

https://dlang.org/dstyle.html#naming_modules

Kind regards
André


More information about the Digitalmars-d mailing list