unittest compiles w/o error though module file is not named after the module

kdevel kdevel at vogtner.de
Sat Feb 6 15:05:30 UTC 2021


On Saturday, 6 February 2021 at 14:52:57 UTC, Adam D. Ruppe wrote:

[...]

> That one `import p;` is kinda weird, it should probably 
> complain then you imported one thing and got another, but 
> generally the name not matching is no problem at all.

```main.d (version 2)
// import x;
unittest {
//   import pp: foo; // wrong name is accepted if x is imported
    import p: foo;
    foo;
}
```

also passes the unittest, same output (void pp.foo()). I am under
the impression that at least this main.d version should fail
because there is no module named "p" (it's named "pp").


More information about the Digitalmars-d-learn mailing list