Since dmd 2.096.0: import `x.t` is used as a type

Steven Schveighoffer schveiguy at gmail.com
Sun May 2 21:29:41 UTC 2021


On 5/2/21 4:32 PM, kdevel wrote:
> On Sunday, 2 May 2021 at 18:36:25 UTC, Basile B. wrote:
> [...]
>> BTW during the PR review the problem you encounter [was 
>> anticipated](https://github.com/dlang/dmd/pull/12178#issuecomment-773886263) 
>> si I guess you're stuck with [the author 
>> answer](https://github.com/dlang/dmd/pull/12178#issuecomment-773902749), 
>> i.e "this worked because of a special case".
> 
> Sure.
> 
>> Again you can still try to get the change turn into a deprecation 
>> first, that'd be legit.
> 
> It only broke the compilation which I already have fixed. Kind of. I 
> would have filed a bug if the runtime went kaput.
> 
> After reading https://dlang.org/spec/module.html#module_declaration 
> again I wonder why there is no advice to avoid module (file) names which 
> equate symbol names defined in the module. I also wonder how I get a 
> module file named ``foo-bar.d`` referenced from another module. 
> Following the advice in the documentation
> 
> ```
> // foo-bar.d
> module foo_bar;
> 
> void foo ()
> {
> }
> 
> // main.d
> import foo_bar;
> 
> void main ()
> {
>    foo;
> }
> ```
> 
> it does not compile:
> 
> ```
> $ dmd -i main.d
> main.d(1): Error: module `foo_bar` is in file 'foo_bar.d' which cannot 
> be read
> ```

In order for that to work, you need to pass the file that contains the 
module to the compiler.

Otherwise, the compiler must assume that the module lives in the file 
named after itself.

-Steve


More information about the Digitalmars-d-learn mailing list