digitalmars.D.learn - "Error: Undefined identifier" when moving import to another module
- nrgyzer (61/61) Oct 19 2014 Hi guys,
- monarch_dodra (5/15) Oct 19 2014 What exactly are you doing here?
- nrgyzer (5/22) Oct 19 2014 "mixing" should be replaced with "mixin": static if (
- monarch_dodra (3/7) Oct 19 2014 Posting full code that actually compiles and reproduces the issue
- nrgyzer (4/12) Oct 19 2014 I posted the full code - except the library. But the library
- Joakim (7/68) Oct 19 2014 An import is private by default:
- nrgyzer (4/89) Oct 20 2014 Hm, I made it public and I'm getting the same error. I also
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?
Oct 19 2014
On Sunday, 19 October 2014 at 09:39:05 UTC, nrgyzer wrote:Hi guys, when I do the following: static if ( isCallable!(mixing(m) )"mixing" ?void main() { /* do something here */ }What exactly are you doing 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 identifierSounds like your import was also import std.typecons which appears to have been required in your main.
Oct 19 2014
On Sunday, 19 October 2014 at 14:48:18 UTC, monarch_dodra wrote:On Sunday, 19 October 2014 at 09:39:05 UTC, nrgyzer wrote:"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).Hi guys, when I do the following: static if ( isCallable!(mixing(m) )"mixing" ?void main() { /* do something here */ }What exactly are you doing 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 identifierSounds like your import was also import std.typecons which appears to have been required in your main.
Oct 19 2014
On Sunday, 19 October 2014 at 16:09:41 UTC, nrgyzer wrote:"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.
Oct 19 2014
On Sunday, 19 October 2014 at 17:14:14 UTC, monarch_dodra wrote:On Sunday, 19 October 2014 at 16:09:41 UTC, nrgyzer wrote: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..."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.
Oct 19 2014
On Sunday, 19 October 2014 at 09:39:05 UTC, nrgyzer wrote: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?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.
Oct 19 2014
On Sunday, 19 October 2014 at 22:22:05 UTC, Joakim wrote:On Sunday, 19 October 2014 at 09:39:05 UTC, nrgyzer wrote: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.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?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.
Oct 20 2014
On Monday, 20 October 2014 at 16:05:14 UTC, nrgyzer wrote:On Sunday, 19 October 2014 at 22:22:05 UTC, Joakim wrote: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...On Sunday, 19 October 2014 at 09:39:05 UTC, nrgyzer wrote: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.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?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.
Oct 20 2014
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?
Oct 20 2014
On Monday, 20 October 2014 at 17:37:34 UTC, nrgyzer wrote: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?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...
Oct 20 2014