Thread overview
[Issue 18517] Import order is not invariant
May 24, 2018
Jonathan Marler
Oct 29, 2018
Walter Bright
Oct 29, 2018
Walter Bright
Oct 30, 2018
Jonathan Marler
Dec 17, 2022
Iain Buclaw
May 24, 2018
https://issues.dlang.org/show_bug.cgi?id=18517

--- Comment #1 from Jonathan Marler <johnnymarler@gmail.com> ---
Added 2 tests to dmd for this bug here: https://github.com/dlang/dmd/pull/8165 but the PR was rejected. Razvan doesn't think tests should be pushed to dmd by themselves (without their corresponding fixes).

> Razvan: I don't see much benefit in having tests that don't pass in the test suite. This puts a burden on the autotester and encourages people to make PRs just with tests creating a separation between the fix and the test.

--
October 29, 2018
https://issues.dlang.org/show_bug.cgi?id=18517

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@yahoo.com
           Severity|enhancement                 |normal

--
October 29, 2018
https://issues.dlang.org/show_bug.cgi?id=18517

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=15086

--
October 29, 2018
https://issues.dlang.org/show_bug.cgi?id=18517

--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> ---
Jonathan Marler's Relevant Pull Requests:

Fix module/import order invariance:

    https://github.com/dlang/dmd/pull/7900

Interpret imports the same regardless of other modules passed on the command line:

    https://github.com/dlang/dmd/pull/7878

Add broken import order invariance tests:

    https://github.com/dlang/dmd/pull/8165

Deprecate import/module name mismatch (ALL CASES):

    https://github.com/dlang/dmd/pull/7778

--
October 30, 2018
https://issues.dlang.org/show_bug.cgi?id=18517

--- Comment #3 from Steven Schveighoffer <schveiguy@yahoo.com> ---
Hm... I didn't realize that the module identifier was not identical to the filename. That is interesting. It's not clearly stated in this bug report that this is a requirement to get the error to occur -- I thought it had something to do with the fact that `thing` appears in both files.

I would expect that if a module is loaded via using the filesystem, and the module name doesn't match how it was found, then this should be an error. Anything else seems to strain your sanity!

In other words, if you pass the modules on the command line, then they can have non-matching filenames, but if they were found via the module name mapping to directories, they had better match the module name.

--
October 30, 2018
https://issues.dlang.org/show_bug.cgi?id=18517

--- Comment #4 from Jonathan Marler <johnnymarler@gmail.com> ---
> I would expect that if a module is loaded via using the filesystem, and the module name doesn't match how it was found, then this should be an error. Anything else seems to strain your sanity!

I thought the same, even made a PR to fix this but was told that by Andrei that Walter didn't want to integrate this restriction.

> In other words, if you pass the modules on the command line, then they can have non-matching filenames, but if they were found via the module name mapping to directories, they had better match the module name.

Agreed, but Walter and Andrei do not.  I believe this is the PR I created to enforce this, https://github.com/dlang/dmd/pull/7878/files but Walter and Andrei discussed this on their own and decided against it.

The unfortunate consequence is that now no matter what we do, you can get different results if you compile different sets of modules, i.e.


dmd -c foo.d bar.d

can be different than

dmd -c foo.d
dmd -c bar.d

there's no way to make these behave the same with their decision not to enforce this rule.  Seems ludicrous to me but not much I can do when they decide to discuss these things behind close doors.

--
October 30, 2018
https://issues.dlang.org/show_bug.cgi?id=18517

--- Comment #5 from Steven Schveighoffer <schveiguy@yahoo.com> ---
I wasn't a part of that conversation, but the "feature" makes no sense -- if you want to import a module and it doesn't reside at the filename that you import, then the system can't find that module. It doesn't make sense that the compiler then "renames" the module after the file name.

Is the conversation listed somewhere on github or the forums? I'd like to reopen that conversation.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=18517

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--