On 08/31/2015 05:35 PM, H. S. Teoh via Digitalmars-d wrote:
On Mon, Aug 31, 2015 at 03:15:07PM +0000, via Digitalmars-d wrote:
I have been bitten by the std.conv.text family of functions twice now
and while it's not a major issue, I think it still an issue that is
worth fixing and perhaps prevent similar issues in the future.

First time I got bitten was because of local imports shadowing local
symbols without error or at least a warning.

auto stuff(string text) {
   import std.conv;

   foreach(ch; text.byDchar) {
   }
}

https://issues.dlang.org/show_bug.cgi?id=10378

Kenji has a pull for this, let's hope it goes through.


T


Of course it is better than the status quo, but if it does, the bug report should stay open, and/or a few new ones should be filed. The pull ignores the discussion about what would be a good design and implements the rather awkward semantics that are quickest to hack into the compiler instead.

Also, the proposed rewrite does not fix the problem. (I haven't tested it, but AFAIU, the following code is neither rejected by the pull, nor does it print "123".)

import std.stdio;

void main(){
    string text="123";
    void foo(){
        import std.conv;
        writeln(text());
    }
    foo();
}


(Also, essentially the same logic occurs in three distinct places in the new code.)

Reply via email to