www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Alias parameter + AA + external module

reply "Dicebot" <m.strashun gmail.com> writes:
== mod.d ==
void func!(alias arr)()
{
     arr["key"] = 43;
}

== test.d ==
import mod;

void main()
{
     auto arr = [ "key" : 42 ];
     func!(arr)();
}

== shell ==
$ rdmd test.d
.../test.o: In function 
`_D4test4mainFZv36__T4funcS24_D4test4mainFZv3arrHAyaiZ4funcMFZv':
test.d:(.text._D4test4mainFZv36__T4funcS24_D4test4mainFZv3arrHA
aiZ4funcMFZv+0x3e): 
undefined reference to `_D3mod7__arrayZ'
collect2: ld returned 1 exit status
--- errorlevel 1

This works if I move func to main module. Also works when passing 
integer variable as an alias param. Also works on x32 linux, but 
fails on x64.

What should I blame and search in bugzilla for? :) My code has 
used this idiom extensively and encountering this while checking 
x64 compatibility was an unpleasant surprise :(
Feb 08 2013
next sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
Dicebot:

 void func!(alias arr)()
 {
     arr["key"] = 43;
 }
I think you have to remove that exclamation mark. Bye, bearophile
Feb 08 2013
parent reply "Dicebot" <m.strashun gmail.com> writes:
On Friday, 8 February 2013 at 15:20:53 UTC, bearophile wrote:
 Dicebot:

 void func!(alias arr)()
 {
    arr["key"] = 43;
 }
I think you have to remove that exclamation mark. Bye, bearophile
Typo, irrelevant to subject.
Feb 08 2013
parent reply "monarch_dodra" <monarchdodra gmail.com> writes:
On Friday, 8 February 2013 at 15:22:09 UTC, Dicebot wrote:
 On Friday, 8 February 2013 at 15:20:53 UTC, bearophile wrote:
 Dicebot:

 void func!(alias arr)()
 {
   arr["key"] = 43;
 }
I think you have to remove that exclamation mark. Bye, bearophile
Typo, irrelevant to subject.
Wait, this is giving me a compile error. You are getting a link error. What's going on?
Feb 08 2013
parent reply "Dicebot" <m.strashun gmail.com> writes:
On Friday, 8 February 2013 at 15:39:05 UTC, monarch_dodra wrote:
 Wait, this is giving me a compile error. You are getting a link 
 error. What's going on?
What compile error do you get? After removing exclamation mark from func declaration it works as described for me.
Feb 08 2013
parent "monarch_dodra" <monarchdodra gmail.com> writes:
On Friday, 8 February 2013 at 16:11:48 UTC, Dicebot wrote:
 On Friday, 8 February 2013 at 15:39:05 UTC, monarch_dodra wrote:
 Wait, this is giving me a compile error. You are getting a 
 link error. What's going on?
What compile error do you get? After removing exclamation mark from func declaration it works as described for me.
I miss-understood you. I thought the ! was the source of the problem. I'm indeed getting the intended link error without it.
Feb 08 2013
prev sibling parent "Dicebot" <m.strashun gmail.com> writes:
Ok, can't find in bugzilla anything similar, have filed new one: 
http://d.puremagic.com/issues/show_bug.cgi?id=9486
Feb 08 2013