Bug 5004 – show both resolved symbols and original identifier in error messages involving aliases

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-10-06T12:20:15Z
Last change time
2024-12-13T17:53:44Z
Keywords
diagnostic
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: dmd#17517 →

Comments

Comment #0 by bearophile_hugs — 2010-10-06T12:20:15Z
The Clang front-end of LLVM tries harder to give good error messages: http://clang.llvm.org/diagnostics.html One simple but nice feature of its error messages is the usage of "aka", this is an example: t.c:13:9: error: member reference base type 'pid_t' (aka 'int') is not a structure or union This is a wrong D2 program: void main() { alias int Foo; Foo f; f = f.x; } DMD 2.049 prints: test.d(4): Error: no property 'x' for type 'int' But a more useful error message can be: test.d(4): Error: no property 'x' for type 'Foo' (aka 'int')
Comment #1 by nfxjfg — 2010-10-06T20:55:51Z
That's a really nice idea! Also see bug 4917.
Comment #2 by nfxjfg — 2010-10-06T20:57:43Z
Trying to improve the bug report title, if you don't mind...
Comment #3 by bearophile_hugs — 2010-10-26T13:36:16Z
Comment #4 by denis.spir — 2011-02-15T14:40:59Z
(In reply to comment #0) > The Clang front-end of LLVM tries harder to give good error messages: > http://clang.llvm.org/diagnostics.html > > One simple but nice feature of its error messages is the usage of "aka", this > is an example: > > t.c:13:9: error: member reference base type 'pid_t' (aka 'int') is not a > structure or union > > > This is a wrong D2 program: > > > void main() { > alias int Foo; > Foo f; > f = f.x; > } > > > DMD 2.049 prints: > test.d(4): Error: no property 'x' for type 'int' > > But a more useful error message can be: > test.d(4): Error: no property 'x' for type 'Foo' (aka 'int') Agreed, would be very nive. Have no idea at which stage in the "decoding" sequence name aliases are resoved, which certainly determines the difficulty of implementing the feature. Anyway, since D's term is 'alias', this term should be used in error messages instead of 'aka'. Also, 'aka' can be difficult for non-english speakers (have learnt it myself only recently, after decades of English practice). 'alias' does not have this issue due to beeing part of D's terminology. However, it goes in opposite sense, I guess: test.d(4): Error: no property 'x' for type 'Foo' (alias for 'int') Or maybe suppleness of English allows the following to be clear? test.d(4): Error: no property 'x' for type 'Foo' ('int' alias) Denis
Comment #5 by bearophile_hugs — 2011-07-18T01:42:25Z
Another similar example of bad error message, DMD 2.054: enum Foo { A } void main() { auto x = Foo.B; } test.d(3): Error: no property 'B' for type 'int'
Comment #6 by bearophile_hugs — 2011-09-18T11:14:04Z
GCC too uses "aka" in error messages: #include <stdint.h> struct S { int16_t x; }; int main(int argc, char **argv) { S s = { argc }; return 0; } ...>g++ -std=c++0x temp.cpp -o temp temp.cpp: In function 'int main(int, char**)': temp.cpp:4:18: error: narrowing conversion of 'argc' from 'int' to 'int16_t {aka short int}' inside { } [-fpermissive]
Comment #7 by bearophile_hugs — 2011-11-15T23:53:47Z
Maybe related to issue 6916
Comment #8 by bearophile_hugs — 2012-03-20T17:10:41Z
This wrong D2 code: T foo(T)(T[] x) { return T[0]; } void main() { foo([1, 2, 3]); } With DMD 2.059head gives: test.d(1): Error: int must be an array or pointer type, not int test.d(3): Error: template instance test.foo!(int) error instantiating But a more readable first error message is like: test.d(1): Error: T (aka 'int') must be an array or pointer type, not int
Comment #9 by bearophile_hugs — 2012-05-06T06:52:35Z
One case: alias ushort UT; void main() { int x; UT y = x; } DMD 2.060alpha gives: test.d(4): Error: cannot implicitly convert expression (x) of type int to ushort But a more useful error message is similar to: test.d(4): Error: cannot implicitly convert expression (x) of type int to UT (alias for ushort) See also Issue 8044
Comment #10 by robert.schadek — 2024-12-13T17:53:44Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17517 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB