digitalmars.D.learn - import conflicts
- AndyC (21/21) Jan 18 2015 Hi all, I'm trying to write my first actual app that'll go into
- Vlad Levenfeld (6/6) Jan 18 2015 I get this all the time with std.array.array (I use my own array
- AndyC (7/14) Jan 18 2015 Ah, if its just a compiler bug I'm ok with that. I was worried
- Mike Parker (11/24) Jan 18 2015 The problem is, that's the bug Vlad was talking about. Selective imports...
Hi all, I'm trying to write my first actual app that'll go into production. My file starts with this set of imports: import std.stdio, std.string, std.json, std.process, std.conv, std.file, core.sys.posix.syslog, tinyredis.redis; import core.sys.posix.unistd: chdir; import core.sys.posix.sys.stat: mkdir, umask; import core.thread: Thread, dur; import core.stdc.stdlib: exit; At some point in code I have added: if (exists("lastUpdate.7z")) { remove("lastUpdate.7z"); } Now I get compile errors: autoupdate.d(183): Error: std.file.remove at /usr/include/dmd/phobos/std/file.d(429) conflicts with core.stdc.stdio.remove at /usr/include/dmd/druntime/import/core/stdc/stdio.d(548) I'm not importing core.stdc.stdio, so why is it conflicting? Thanks for your time, -Andy
Jan 18 2015
I get this all the time with std.array.array (I use my own array implementations, but phobos' array seems to secretly creep in everywhere). I think its got to do with that private import visibility bug (https://issues.dlang.org/show_bug.cgi?id=314 or https://issues.dlang.org/show_bug.cgi?id=13096 I think) which, by the looks of it, should be getting a fix... soon? ish?
Jan 18 2015
On Sunday, 18 January 2015 at 19:20:34 UTC, Vlad Levenfeld wrote:I get this all the time with std.array.array (I use my own array implementations, but phobos' array seems to secretly creep in everywhere). I think its got to do with that private import visibility bug (https://issues.dlang.org/show_bug.cgi?id=314 or https://issues.dlang.org/show_bug.cgi?id=13096 I think) which, by the looks of it, should be getting a fix... soon? ish?Ah, if its just a compiler bug I'm ok with that. I was worried there was something about the language I didnt understand. I got it to compile ok using: import std.file: remove, exists, rename; Thanks, -Andy
Jan 18 2015
On 1/19/2015 4:37 AM, AndyC wrote:On Sunday, 18 January 2015 at 19:20:34 UTC, Vlad Levenfeld wrote:The problem is, that's the bug Vlad was talking about. Selective imports wind up becoming public, polluting the namespace. The thing to do when you get conflicts is to use the fully-qualified function name, like so: std.file.remove( "lastUpdate.7z" ); Keep those selective imports out of module scope until the bug is fixed. They work in local scope just fine: void foo() { import std.file : remove, exists; if( exists( "foo" )) remove( "foo" ); }I get this all the time with std.array.array (I use my own array implementations, but phobos' array seems to secretly creep in everywhere). I think its got to do with that private import visibility bug (https://issues.dlang.org/show_bug.cgi?id=314 or https://issues.dlang.org/show_bug.cgi?id=13096 I think) which, by the looks of it, should be getting a fix... soon? ish?Ah, if its just a compiler bug I'm ok with that. I was worried there was something about the language I didnt understand. I got it to compile ok using: import std.file: remove, exists, rename; Thanks, -Andy
Jan 18 2015