digitalmars.D.learn - object hijacked ?
- Jacob Carlborg (17/17) Oct 09 2014 I have a file named "Object.d", in a directory called "foo". The module
- Dicebot (6/6) Oct 09 2014 I think this is an issue with the import resolution, not module
- Jacob Carlborg (5/10) Oct 09 2014 So it just picks the first filename matching "object" and doesn't care
I have a file named "Object.d", in a directory called "foo". The module name of this file is "foo.Object". As it happens, I'm using OS X which uses a case insensitive file system. I also have another file, say "Bar.d" in "foo", with the module name "foo.Bar". When I try to compile/run Bar.d with rdmd as follows: rdmd foo/Bar.d I get a lot of errors like "undefined identifier string" and "undefined identifier size_t" from some modules in druntime and Phobos. If I rename "foo/Object.d" to "foo/Object2.d", leaving the module name as "foo.Object" everything works as expected. WAT?? I thought D's module system would prevent mistakes like this. Is this the expected behavior? I think the issue is that "rdmd" adds a flag, "-Ifoo", when running dmd to get the dependencies. But the module system should still prevent it. It seems like the compiler uses the filename instead of the declared module name as the module name. -- /Jacob Carlborg
Oct 09 2014
I think this is an issue with the import resolution, not module system. The way it is implemented right now DMD stops searching for object.d / object.di once it has found one. So while your module name is not interpreted as "object" _original_ object.di does not get imported and you get lot of different issues from missing declarations.
Oct 09 2014
On 09/10/14 22:06, Dicebot wrote:I think this is an issue with the import resolution, not module system. The way it is implemented right now DMD stops searching for object.d / object.di once it has found one. So while your module name is not interpreted as "object" _original_ object.di does not get imported and you get lot of different issues from missing declarations.So it just picks the first filename matching "object" and doesn't care about its module name. -- /Jacob Carlborg
Oct 09 2014