Discussion:
"Error: Undefined identifier" when moving import to another module
nrgyzer via Digitalmars-d-learn
2014-10-19 09:39:03 UTC
Permalink
Hi guys,

when I do the following:

module myMain;

import example;
import std.traits;
import my.static.library.binding;

static this()
{
foreach ( m; __traits(allMembers, example) )
{
static if ( isCallable!(mixing(m) )
{
// ... do something here
}
}
}

void main() { /* do something here */ }

And my example-module looks like:

module example;

void exmapleFunction()
{
// do something here
}

I can compile my application without any error, BUT when I move
the import of "my.static.library.binding" to the example-module:

module example;

import my.static.library.binding;

void exmapleFunction()
{
// do something here
}

... I'm getting many error messages like these:

myMain.d-mixin-11(11): Error: undefined identifier
_D12TypeInfo_xAa6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D49TypeInfo_xAS3std8typecons16__T5TupleTkTkTkZ5Tuple6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D75TypeInfo_xAS3std3uni38__T13InversionListTS3std3uni8GcPolicyZ13InversionList6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D55TypeInfo_xAE3std5regex15__T6ParserTAyaZ6Parser8Operator6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D31TypeInfo_xAS3std5regex8Bytecode6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D110TypeInfo_xAS3std3uni152__T4TrieTS3std3uni20__T9BitPackedTbVmi1Z9BitPackedTwVmi1114112TS3std3uni23__T9sliceBitsVmi8Vmi21Z9sliceBitsTS3std3uni22__T9sliceBitsVmi0Vmi8Z9sliceBitsZ4Trie6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D45TypeInfo_xS3std5regex14__T7ShiftOrTaZ7ShiftOr6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D11TypeInfo_xw6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D11TypeInfo_xb6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D13TypeInfo_xAya6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D41TypeInfo_xS3std5regex12__T5StackTkZ5Stack6__initZ

I'm having no idea what's going wrong here. I'm simply moving the
import from the file where my main() is located in to the
example-module. When removing the import of
"my.static.library.binding" in the example-module allows me to
successfully compile everything. But I need the import in the
example-module. Any suggestions what's going wrong here/how I can
solve the error?
monarch_dodra via Digitalmars-d-learn
2014-10-19 14:48:17 UTC
Permalink
Post by nrgyzer via Digitalmars-d-learn
Hi guys,
static if ( isCallable!(mixing(m) )
"mixing" ?
Post by nrgyzer via Digitalmars-d-learn
void main() { /* do something here */ }
What exactly are you doing here?
Post by nrgyzer via Digitalmars-d-learn
myMain.d-mixin-11(11): Error: undefined identifier
_D12TypeInfo_xAa6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D49TypeInfo_xAS3std8typecons16__T5TupleTkTkTkZ5Tuple6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
Sounds like your import was also import std.typecons which
appears to have been required in your main.
nrgyzer via Digitalmars-d-learn
2014-10-19 16:09:38 UTC
Permalink
Post by monarch_dodra via Digitalmars-d-learn
Post by nrgyzer via Digitalmars-d-learn
Hi guys,
static if ( isCallable!(mixing(m) )
"mixing" ?
Post by nrgyzer via Digitalmars-d-learn
void main() { /* do something here */ }
What exactly are you doing here?
Post by nrgyzer via Digitalmars-d-learn
myMain.d-mixin-11(11): Error: undefined identifier
_D12TypeInfo_xAa6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D49TypeInfo_xAS3std8typecons16__T5TupleTkTkTkZ5Tuple6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
Sounds like your import was also import std.typecons which
appears to have been required in your main.
"mixing" should be replaced with "mixin": static if (
isCallable!(mixin(m) )

My main is empty in both cases. So nothing done in my main
(currently).
monarch_dodra via Digitalmars-d-learn
2014-10-19 17:14:12 UTC
Permalink
Post by nrgyzer via Digitalmars-d-learn
"mixing" should be replaced with "mixin": static if (
isCallable!(mixin(m) )
My main is empty in both cases. So nothing done in my main
(currently).
Posting full code that actually compiles and reproduces the issue
helps.
nrgyzer via Digitalmars-d-learn
2014-10-19 18:31:06 UTC
Permalink
Post by monarch_dodra via Digitalmars-d-learn
Post by nrgyzer via Digitalmars-d-learn
"mixing" should be replaced with "mixin": static if (
isCallable!(mixin(m) )
My main is empty in both cases. So nothing done in my main
(currently).
Posting full code that actually compiles and reproduces the
issue helps.
I posted the full code - except the library. But the library
contains over hundred thousand lines of code, so I think that's a
bit too much to post here...
Joakim via Digitalmars-d-learn
2014-10-19 22:22:05 UTC
Permalink
Post by nrgyzer via Digitalmars-d-learn
Hi guys,
module myMain;
import example;
import std.traits;
import my.static.library.binding;
static this()
{
foreach ( m; __traits(allMembers, example) )
{
static if ( isCallable!(mixing(m) )
{
// ... do something here
}
}
}
void main() { /* do something here */ }
module example;
void exmapleFunction()
{
// do something here
}
I can compile my application without any error, BUT when I move
module example;
import my.static.library.binding;
void exmapleFunction()
{
// do something here
}
myMain.d-mixin-11(11): Error: undefined identifier
_D12TypeInfo_xAa6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D49TypeInfo_xAS3std8typecons16__T5TupleTkTkTkZ5Tuple6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D75TypeInfo_xAS3std3uni38__T13InversionListTS3std3uni8GcPolicyZ13InversionList6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D55TypeInfo_xAE3std5regex15__T6ParserTAyaZ6Parser8Operator6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D31TypeInfo_xAS3std5regex8Bytecode6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D110TypeInfo_xAS3std3uni152__T4TrieTS3std3uni20__T9BitPackedTbVmi1Z9BitPackedTwVmi1114112TS3std3uni23__T9sliceBitsVmi8Vmi21Z9sliceBitsTS3std3uni22__T9sliceBitsVmi0Vmi8Z9sliceBitsZ4Trie6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D45TypeInfo_xS3std5regex14__T7ShiftOrTaZ7ShiftOr6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D11TypeInfo_xw6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D11TypeInfo_xb6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D13TypeInfo_xAya6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D41TypeInfo_xS3std5regex12__T5StackTkZ5Stack6__initZ
I'm having no idea what's going wrong here. I'm simply moving
the import from the file where my main() is located in to the
example-module. When removing the import of
"my.static.library.binding" in the example-module allows me to
successfully compile everything. But I need the import in the
example-module. Any suggestions what's going wrong here/how I
can solve the error?
An import is private by default:

http://dlang.org/module.html

When you move the import of my.static.library.binding to the
"example" module, its declarations are no longer available in the
"myMain" module. You'd have to make it a "public import
my.static.library.binding" to make it available to other modules.
nrgyzer via Digitalmars-d-learn
2014-10-20 16:05:12 UTC
Permalink
Post by Joakim via Digitalmars-d-learn
Post by nrgyzer via Digitalmars-d-learn
Hi guys,
module myMain;
import example;
import std.traits;
import my.static.library.binding;
static this()
{
foreach ( m; __traits(allMembers, example) )
{
static if ( isCallable!(mixing(m) )
{
// ... do something here
}
}
}
void main() { /* do something here */ }
module example;
void exmapleFunction()
{
// do something here
}
I can compile my application without any error, BUT when I
move the import of "my.static.library.binding" to the
module example;
import my.static.library.binding;
void exmapleFunction()
{
// do something here
}
myMain.d-mixin-11(11): Error: undefined identifier
_D12TypeInfo_xAa6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D49TypeInfo_xAS3std8typecons16__T5TupleTkTkTkZ5Tuple6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D75TypeInfo_xAS3std3uni38__T13InversionListTS3std3uni8GcPolicyZ13InversionList6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D55TypeInfo_xAE3std5regex15__T6ParserTAyaZ6Parser8Operator6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D31TypeInfo_xAS3std5regex8Bytecode6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D110TypeInfo_xAS3std3uni152__T4TrieTS3std3uni20__T9BitPackedTbVmi1Z9BitPackedTwVmi1114112TS3std3uni23__T9sliceBitsVmi8Vmi21Z9sliceBitsTS3std3uni22__T9sliceBitsVmi0Vmi8Z9sliceBitsZ4Trie6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D45TypeInfo_xS3std5regex14__T7ShiftOrTaZ7ShiftOr6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D11TypeInfo_xw6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D11TypeInfo_xb6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D13TypeInfo_xAya6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D41TypeInfo_xS3std5regex12__T5StackTkZ5Stack6__initZ
I'm having no idea what's going wrong here. I'm simply moving
the import from the file where my main() is located in to the
example-module. When removing the import of
"my.static.library.binding" in the example-module allows me to
successfully compile everything. But I need the import in the
example-module. Any suggestions what's going wrong here/how I
can solve the error?
http://dlang.org/module.html
When you move the import of my.static.library.binding to the
"example" module, its declarations are no longer available in
the "myMain" module. You'd have to make it a "public import
my.static.library.binding" to make it available to other
modules.
Hm, I made it public and I'm getting the same error. I also
imported the same module in my main which also gives me the same
error.
nrgyzer via Digitalmars-d-learn
2014-10-20 16:55:39 UTC
Permalink
Post by nrgyzer via Digitalmars-d-learn
Post by Joakim via Digitalmars-d-learn
Post by nrgyzer via Digitalmars-d-learn
Hi guys,
module myMain;
import example;
import std.traits;
import my.static.library.binding;
static this()
{
foreach ( m; __traits(allMembers, example) )
{
static if ( isCallable!(mixing(m) )
{
// ... do something here
}
}
}
void main() { /* do something here */ }
module example;
void exmapleFunction()
{
// do something here
}
I can compile my application without any error, BUT when I
move the import of "my.static.library.binding" to the
module example;
import my.static.library.binding;
void exmapleFunction()
{
// do something here
}
myMain.d-mixin-11(11): Error: undefined identifier
_D12TypeInfo_xAa6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D49TypeInfo_xAS3std8typecons16__T5TupleTkTkTkZ5Tuple6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D75TypeInfo_xAS3std3uni38__T13InversionListTS3std3uni8GcPolicyZ13InversionList6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D55TypeInfo_xAE3std5regex15__T6ParserTAyaZ6Parser8Operator6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D31TypeInfo_xAS3std5regex8Bytecode6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D110TypeInfo_xAS3std3uni152__T4TrieTS3std3uni20__T9BitPackedTbVmi1Z9BitPackedTwVmi1114112TS3std3uni23__T9sliceBitsVmi8Vmi21Z9sliceBitsTS3std3uni22__T9sliceBitsVmi0Vmi8Z9sliceBitsZ4Trie6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D45TypeInfo_xS3std5regex14__T7ShiftOrTaZ7ShiftOr6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D11TypeInfo_xw6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D11TypeInfo_xb6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D13TypeInfo_xAya6__initZ
myMain.d-mixin-11(11): Error: undefined identifier
_D41TypeInfo_xS3std5regex12__T5StackTkZ5Stack6__initZ
I'm having no idea what's going wrong here. I'm simply moving
the import from the file where my main() is located in to the
example-module. When removing the import of
"my.static.library.binding" in the example-module allows me
to successfully compile everything. But I need the import in
the example-module. Any suggestions what's going wrong
here/how I can solve the error?
http://dlang.org/module.html
When you move the import of my.static.library.binding to the
"example" module, its declarations are no longer available in
the "myMain" module. You'd have to make it a "public import
my.static.library.binding" to make it available to other
modules.
Hm, I made it public and I'm getting the same error. I also
imported the same module in my main which also gives me the
same error.
I temporarely solved the error by making the import in the module
where the main()-function is located in public and importing this
file into the other module. This solved the error but is not a
perfect solution...
nrgyzer via Digitalmars-d-learn
2014-10-20 17:37:33 UTC
Permalink
This solved the problem for the first time, BUT - I don't know if
it's a bug or a feature - I ran into another problem. I'm having
the following few lines:

module example;

private
{
string[string] myPrivateArray;
}

static this()
{
foreach ( m; __traits(allMembers, example) )
{

writefln("%s ::> %s", m, __traits(getProtection, m));
}
}

void main() { /* empty */ }

Compiling and running the application say's that myPrivateArray
is public:

myPrivateArray ::> public

I declared myPrivateArray using the private keyword, but the
dmd-trait `getProtection` says public. Why?
nrgyzer via Digitalmars-d-learn
2014-10-20 17:48:29 UTC
Permalink
Post by nrgyzer via Digitalmars-d-learn
This solved the problem for the first time, BUT - I don't know
if it's a bug or a feature - I ran into another problem. I'm
module example;
private
{
string[string] myPrivateArray;
}
static this()
{
foreach ( m; __traits(allMembers, example) )
{
writefln("%s ::> %s", m, __traits(getProtection, m));
}
}
void main() { /* empty */ }
Compiling and running the application say's that myPrivateArray
myPrivateArray ::> public
I declared myPrivateArray using the private keyword, but the
dmd-trait `getProtection` says public. Why?
Ah, okay, I also need to use mixin(m) to get the protection. But
in this case, getProtection only works if I want retrieve the
protection for a variable, contained in the same module. I simply
can't use getProtection if I'm using the allMembers-trait for
another module where the variable is private...

Loading...