Forbidden file names?

Paul Backus snarwin at gmail.com
Sun Mar 14 20:57:39 UTC 2021


On Sunday, 14 March 2021 at 20:47:00 UTC, Brian wrote:
> Hello --
>
> Apologies if this is answered somewhere in the documentation.
> I was trying out the sample code on the dlang.org home page.
>
> When I got to the "Sort an Array at Compile-Time" example, I 
> saved it on my machine as sort.d. When I tried to build sort.d, 
> the compile failed. But when I renamed sort.d to anything else 
> (e.g., array.d), the compilation was fine.
[...]
> /home/brian/d $ dmd sort.d
> sort.d(9): Error: function expected before `()`, not `module 
> sort` of type `void`

This is the error you get when you try to call a function that 
has the same name as the current module. The best way to fix it 
is to rename the module, but if you can't, you can use an alias 
to disambiguate:

     alias sort = std.algorithm.sort;


More information about the Digitalmars-d-learn mailing list