www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14397] New: dmd: Provide full source range for compiler


          Issue ID: 14397
           Summary: dmd: Provide full source range for compiler errors
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: bruno.do.medeiros+deebugz gmail.com

When a D source file has an error, only the line number is reported by the
compiler. So for example, with:
void func() {
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
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:


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.

Apr 02 2015