-
-
Notifications
You must be signed in to change notification settings - Fork 668
Interpret imports the same regardless of other modules passed on the command line #7878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for your pull request and interest in making D better, @marler8997! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
|
af2f88d to
2cc2b19
Compare
e0574ff to
52f26e9
Compare
52f26e9 to
50992e6
Compare
I don't see how this makes sense. The modules are Fixing just the test case of 15086 is fine by me, though. As long as this doesn't allow more broken stuff than we currently have. I can just file another issue for the partial matching thing. |
50992e6 to
4b77922
Compare
This is currently being debated between @WalterBright, @andralex and myself (see #7778). They currently don't see this as a problem.
This PR does not allow anything that wasn't already allowed, it is only restricting the use case described. |
4b77922 to
feb6bb6
Compare
|
I should mention that importing a module using it's filename, when it's module name does not match is already an error, it just doesn't get detected if you don't pass both files to the compiler on the same invocation. i.e. // main.d
import foo;
void main() { }// foo.d
module bar;If you compile them separately using 2 invocations dmd -c main.d
dmd -c foo.dIt works, but if you compile them with one invocation (note still using dmd -c main.d foo.dit will fail with This should not be. Either both cases should fail or both should pass. Note that by continuing to support this feature, an import statement can result in different behavior depending on how the compiler is invoked. To demonstrate, consider import foo;What does this mean? Currently, it does not necessarily mean you are importing a module named foo. When the import is processed, if there so happens to be a module named |
… the command line Fix issue 15086
feb6bb6 to
2fe2d87
Compare
|
Had a long discussion with @WalterBright. Of the cases initially presented, this is the one with most merit. The following will focus on it, although certain considerations apply beyond. Meta: the incumbent behavior has extra weight by means of being incumbent. We need to make a strong case to displace it. History: initially module declarations were a lot stricter. That turned out early on to be too rigid to be workable. That doesn't dismiss revisiting it outright, but does stand as a warning. 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: any number of changes in the way binaries are built influence the result, and some are not workable. Furthermore, the added value of changing that should be argued (see "Meta"): what problem is this fixing? The error message plainly tells what must be done. We should enhance it. A stronger case would be made by showing how unwitting code compiles in two distinct and plausible cases, yet behaves differently at runtime. "Unwitting" is an important detail because matters can be manipulated on the filesystem side - see below. The second point made is that simple imports such as What Another good argument in favor of this PR could be constructed by showing that semantics of a successful build depend on the order in which files are specified. Order dependency is easy to characterize as undesirable. |
This is what I believe to be the strongest argument for this PR. If this argument does not justify it then it's dead. Closing. |
|
In the future, I think we can be more efficient with our time if concerns about a bug not being a bug are voiced before a PR is created for it. Especially when that bug has been around for 2 and a half years. |
|
@marler8997 You are certainly right, and I apologize. This has been off my radar. |
This PR unifies the behavior of imports regardless of what modules were given on the command line (https://issues.dlang.org/show_bug.cgi?id=15086). Consider the following:
The above code will fail if compiled together, i.e.
However, if you compile them using 2 invocations, it will succeed:
This PR unifies both cases by making them both fail with the same error message.