Bug 12598 – Poor diagnostic with local import hijacking

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-04-19T11:12:00Z
Last change time
2014-04-19T18:26:39Z
Keywords
diagnostic
Assigned to
andrej.mitrovich
Creator
dlang-bugzilla

Comments

Comment #0 by dlang-bugzilla — 2014-04-19T11:12:30Z
Consider the following program: //////////////////// test.d //////////////////// class C { void addLine(string l) { debug { import std.stdio; stderr.writeln("Adding line: " ~ l); } lines ~= l; } immutable(string)[] lines; } //////////////////////////////////////////////// When compiled with -debug, the compiler produces the following error message: test.d(10,3): Error: lines is not an lvalue This error message is misleading - it's not clear that a symbol from std.stdio is hijacking the "lines" field. One way to improve the situation is to print fully-qualified symbol names in error messages. Another would be to add a warning or error when a locally-imported symbol is hijacking a non-global symbol. The user can silence this message by using a selective, static or named import.
Comment #1 by github-bugzilla — 2014-04-19T18:26:39Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/776cc73b4afc04e22bbc06f3e3b370cd5c90c5a5 Fix Issue 12598 - Emit better diagnostics when type is found where an lvalue was expected. https://github.com/D-Programming-Language/dmd/commit/c643ec572f8c528225c6a6af1594b08b04488657 Merge pull request #3470 from AndrejMitrovic/Fix12598 Issue 12598 - Emit better diagnostics when type is found where an lvalue was expected