Open AndrejMitrovic opened 1 year ago
I also think this could be implemented in the compiler, but I'm really not sure if it belongs there or here..
I wrote a really silly script that helps me work around the issue: run_dub.d
Then I just run it as run_dub dub -q build --root=examples/hello
and get nice full paths in the errors:
examples\hello\src\hello\main.d(18,5): Error: undefined identifier `Foo`
Error C:\Apps\DMD\dmd2\windows\bin\dmd.exe failed with exit code 1.
I'm sure It's overkill. 😄
Currently the [dmd] compiler emits errors with either relative or absolute paths, based upon what was provided on the command-line.
For example:
When using build tools like dub and code editors it can be hard to quickly jump to the file + location of a compile-time error when the errors show relative paths.
For example, I have a dub library project with some example code. I set up a shortcut in my editor to run
dub build --root=examples/hello
. And my actual directory structure is:Here's a compiler error:
In the editor I have a hook for quickly jumping to the offending file + line by parsing the compiler's output. Easily done with a regex:
But the problem is my editor doesn't know anything about dub's
--root
command, and so it doesn't know how to find the filesrc\hello\main.d(18,5)
, because the real path relative to the editor's current working directory isexamples\hello\src\hello\main.d
.This could be worked around in various ways in the editor of choice, but it would be easier if we had a way of telling dub to pass absolute file and import paths to the compiler. Then jumping to the correct file is trivial.
The downside is dub could reach some platform limitations with this switch enabled. For example command prompt line string limitations, or some other syscall limitations.
Curious about your thoughts~