Bug 14397 – dmd: Provide full source range for compiler errors [enhancement]

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-04-03T00:38:06Z
Last change time
2024-12-13T18:41:52Z
Assigned to
No Owner
Creator
Bruno Medeiros
Moved to GitHub: dmd#18969 →

Comments

Comment #0 by bruno.do.medeiros+deebugz — 2015-04-03T00:38:06Z
When a D source file has an error, only the line number is reported by the compiler. So for example, with: ``` void func() { writelnxxx("Hello"); } ``` the compiler error message: `test.d(2): Error: undefined identifier writelnxxx` This is okay for command line usage, but when the compiler is invoked by editors and IDEs, it would be an improvement if a full source range was reported - that is, the start offset (line+column) of the error, and the end offset (line+column). The option -vcolumns prints the column of the start of the error... but that is not very useful unless the end of the range is reported as well! As an example, here's the error output from the Rust compiler for a similar error: ``` src\main.rs:8:5: 8:15 error: macro undefined: 'printlnxxx!' src\main.rs:8 printlnxxx!("Hello world"); ^~~~~~~~~~ ``` Here, the Rust compiler provides "8:5" as the start of the error range and "8:15" the end of the range. Reporting the error location as absolute character offsets from the start of the file (as opposed to line+column), would also work fine (a start offset and an end offset). With this, IDEs and editors can present errors as squiggly lines in a source editor. Example, see how "xxx" is underlined: https://cloud.githubusercontent.com/assets/4324232/6976292/8f01c25c-d99f-11e4-9b35-db9d380d2bd3.png As a sidenote, https://github.com/bruno-medeiros/DDT/ in particular already supports this functionality, but it needs the compiler to report the full source ranges.
Comment #1 by doob — 2015-04-03T08:21:07Z
Would be nice of have. Clang and Xcode (which uses Clang) both have this feature.
Comment #2 by robert.schadek — 2024-12-13T18:41:52Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18969 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB