Jump to page: 1 24  
Page
Thread overview
[Issue 15086] import doesn't verify module declaration
Oct 15, 2015
Vladimir Panteleev
Jan 26, 2018
Timothee Cour
Feb 12, 2018
Walter Bright
Feb 12, 2018
Jonathan M Davis
Feb 12, 2018
Jonathan Marler
Feb 13, 2018
Jonathan Marler
Feb 13, 2018
Jonathan Marler
Feb 13, 2018
Timothee Cour
Feb 13, 2018
ag0aep6g@gmail.com
Feb 13, 2018
Timothee Cour
Feb 13, 2018
Jonathan Marler
Feb 13, 2018
Timothee Cour
Feb 13, 2018
ag0aep6g@gmail.com
Feb 13, 2018
Jonathan Marler
Feb 14, 2018
Walter Bright
Feb 14, 2018
Timothee Cour
Feb 14, 2018
Jonathan Marler
Feb 14, 2018
Jonathan Marler
Feb 14, 2018
ag0aep6g@gmail.com
Feb 14, 2018
Jonathan Marler
Feb 16, 2018
Jonathan Marler
Feb 16, 2018
Timothee Cour
Oct 29, 2018
Walter Bright
Feb 06, 2021
kdevel
Dec 17, 2022
Iain Buclaw
Dec 24, 2022
Adam D. Ruppe
Dec 25, 2022
Walter Bright
Jun 30
ag0aep6g
October 15, 2015
https://issues.dlang.org/show_bug.cgi?id=15086

Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow@gmail.com

--- Comment #1 from Vladimir Panteleev <thecybershadow@gmail.com> ---
I think this is a dupe of some ancient bug... IIRC, the gist of the situation is that it would preclude object_.d from compiling.

Oh, but object_.d is now called object.d, so this might be relevant again.

--
January 26, 2018
https://issues.dlang.org/show_bug.cgi?id=15086

Timothee Cour <timothee.cour2@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timothee.cour2@gmail.com
           Hardware|x86_64                      |All
                 OS|Linux                       |All
           Severity|minor                       |critical

--- Comment #2 from Timothee Cour <timothee.cour2@gmail.com> ---
just ran into this again, this is a serious hole in the D module system.

Here was the example i was gonna report:


```dmd -I. main.d
main
bar // BUG! was imported as foo.bar (inconsistent)
foo.bar2
asdf.wrong // BUG! was imported as foo.bar (inconsistent)
```

```pragma(msg, __MODULE__);
import foo.bar;
import foo.bar2;
import foo.bar3;
void main(){}

cat foo/bar.d
pragma(msg, __MODULE__);
cat foo/bar2.d

cat foo/bar2.d
module foo.bar2;
pragma(msg, __MODULE__);

cat foo/bar3.d
module asdf.wrong;
pragma(msg, __MODULE__);
```



LINKS:
https://github.com/dlang/dmd/pull/7778 Bug fix: dmd allows importing modules
with wrong name #7778

--
February 12, 2018
https://issues.dlang.org/show_bug.cgi?id=15086

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei@erdani.com

--- Comment #3 from Andrei Alexandrescu <andrei@erdani.com> ---
(In reply to Timothee Cour from comment #2)
> just ran into this again, this is a serious hole in the D module system.
> 
> Here was the example i was gonna report:
> 
> 
> ```dmd -I. main.d
> main
> bar // BUG! was imported as foo.bar (inconsistent)
> foo.bar2
> asdf.wrong // BUG! was imported as foo.bar (inconsistent)
> ```
> 
> ```pragma(msg, __MODULE__);
> import foo.bar;
> import foo.bar2;
> import foo.bar3;
> void main(){}
> 
> cat foo/bar.d
> pragma(msg, __MODULE__);
> cat foo/bar2.d
> 
> cat foo/bar2.d
> module foo.bar2;
> pragma(msg, __MODULE__);
> 
> cat foo/bar3.d
> module asdf.wrong;
> pragma(msg, __MODULE__);
> ```
> 
> 
> 
> LINKS:
> https://github.com/dlang/dmd/pull/7778 Bug fix: dmd allows importing modules
> with wrong name #7778

Can you please reorganize the examples? It is difficult to understand which files have which content. Thanks!

--
February 12, 2018
https://issues.dlang.org/show_bug.cgi?id=15086

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> ---
Why is this "critical"? I'm not even convinced it's a bug at all. The language does, after all, allow module names to be different from file names.

--
February 12, 2018
https://issues.dlang.org/show_bug.cgi?id=15086

Jonathan M Davis <issues.dlang@jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dlang@jmdavisProg.co
                   |                            |m

--- Comment #5 from Jonathan M Davis <issues.dlang@jmdavisProg.com> ---
(In reply to Walter Bright from comment #4)
> Why is this "critical"? I'm not even convinced it's a bug at all. The language does, after all, allow module names to be different from file names.

Well, it's allowing you to import a module with the wrong name. So, I don't see how it can really be argued that it isn't a bug, but I agree that it isn't particularly critical.

Honestly, I think that it was a mistake to allow the module declaration to not match the file name, but that can be argued, and we're stuck with it at this point, since it's doubtful that changing it would be worth the breakage. Either way, being allowed to import the same module with two different names doesn't seem like it improves things, and the module declaration is supposed to be giving the module its name, so as long as it's allowed to not match the file name, I would fully expect importing using the file name to fail if it doesn't match the module declaration.

--
February 12, 2018
https://issues.dlang.org/show_bug.cgi?id=15086

Jonathan Marler <johnnymarler@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |johnnymarler@gmail.com

--- Comment #6 from Jonathan Marler <johnnymarler@gmail.com> ---
Note that there are 3 names to consider for every import.

1. The import name
2. The file name
3. The module name

This issue addresses the case where the import name matches the filename, but does not match the module name.

> Note that it does not cover the case where the import matches the module name but does not match the filename (a case I think is useful).

The problem is that this is an error when all the modules are compiled together, but the error disappears if you compile the modules seperately. This puts a coupling between the module system and how the source files are compiled, and adds support for an odd use case that has no utility.

--
February 13, 2018
https://issues.dlang.org/show_bug.cgi?id=15086

Jonathan Marler <johnnymarler@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #7 from Jonathan Marler <johnnymarler@gmail.com> ---
Andrei and Waltered have rules this as not a bug:

https://github.com/dlang/dmd/pull/7878#issuecomment-365354972
> The case for this PR rests on the notion there should be some invariance of build results with changing build conditions. E.g. "Either both cases should fail or both should pass" (and let me add: "... and create the same binary"). That actually doesn't seem to be a strong argument...

--
February 13, 2018
https://issues.dlang.org/show_bug.cgi?id=15086

--- Comment #8 from Andrei Alexandrescu <andrei@erdani.com> ---
I think at the least we can do a vastly better job at issuing error messages. Per the discussion in :

===
This error occurs becase the module foo/bar.d is being loaded twice with 2
different names. The first time it is loaded because it is given on the command
line, and since it has no module declaration, the compiler gives it the name
bar. But then the module gets imported with the name foo.bar, however, the
compiler cannot change the name of the module and all existing reference to it
so an error must be asserted.
[...]
[this bug is allowing] weird abuses which in my opinion have no utility and
only serve to add confusion to the module system.
===

I do agree matters can be confusing especially during project organization and reorganization. I've done my share of head scratching. I think we'd go a long way with better error messages (e.g. explaining the matter with two access paths above), and better online documentation for the module directive.

--
February 13, 2018
https://issues.dlang.org/show_bug.cgi?id=15086

--- Comment #9 from Andrei Alexandrescu <andrei@erdani.com> ---
Meant to write:

Per the discussion in https://github.com/dlang/dmd/pull/7778

--
February 13, 2018
https://issues.dlang.org/show_bug.cgi?id=15086

--- Comment #10 from Jonathan Marler <johnnymarler@gmail.com> ---
> I think at the least we can do a vastly better job at issuing error messages.

I'm limiting focus to this issue alone. Do you have an idea on a way to improve the error message for this case?

CURRENT BEHAVIOR
----------------------------
dmd -c foo.d bar.d
Error: module baz from file bar.d must be imported with 'import baz;'

PROPOSED BEHAVIOR
----------------------------
dmd -c foo.d bar.d
Error: module baz from file bar.d must be imported with 'import baz;' or must
be compiled separately

--
« First   ‹ Prev
1 2 3 4