Bug 24476 – Show error for missing import path

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2024-04-01T09:46:01Z
Last change time
2024-04-05T14:39:04Z
Assigned to
No Owner
Creator
Tim

Comments

Comment #0 by tim.dlang — 2024-04-01T09:46:01Z
When a module can't be found, DMD will currently show an error message like this: ``` dmd -Itestpackage test.d test.d(1): Error: unable to read module `testmodule` test.d(1): Expected 'testmodule.d' or 'testmodule/package.d' in one of the following import paths: import path[0] = testpackage import path[1] = /usr/include/dlang/dmd ``` In this case the directory `testpackage` does not exist, but that is not visible from the error message. It would be helpful to directly show an error message when parameter `-Itestpackage` is used, but directory `testpackage` does not exist. Unfortunately that could break existing projects. Alternatively the error message for a missing module could be improved like this: ``` test.d(1): Error: unable to read module `testmodule` test.d(1): Expected 'testmodule.d' or 'testmodule/package.d' in one of test.d(1): Error: import path 'testpackage' does not exist the following import paths: import path[0] = testpackage import path[1] = /usr/include/dlang/dmd ```
Comment #1 by razvan.nitu1305 — 2024-04-05T14:39:04Z
It is not the compiler's job to check whether directories specified with -I exist or not. That's really up to the build system. Additionally, the first thing you do when you get such error messages is to check whether the file mentioned in the error message actually exists in the printed import paths. So in the majority of the situations it's gonna be really obvious if an important does not exist or not. I don't really see any real benefit in adding this in the compiler and exposing ourselves to potential breakage.