So after that last bit of EXPORT weirdness, I went to apply lessons learned to the actual project, and the bloody error returned. I have now linked the cause to specific require statements:
sub EXPORT(+@a) {
# cw: Implement SELECTIVE loading if necessary.
@color_list = @a.elems > 0 ??
@color_lists_found.grep(@a.any)
!!
@color_lists_found;
#if $color_support {
# require Color;
#}
#for @color_list -> $cl {
# say "L: $cl";
# require ::("Color::Names::{$cl}");
#}
# cw: What we always export.
#
# Is there any way to get EXPORT::DEFAULT from the module block?
{
'&lists_available' => ::('&Color::Names::lists_available'),
'&lists_loaded' => ::('&Color::Names::lists_loaded'),
'&location' => ::('&Color::Names::location'),
'&color' => ::('&Color::Names::color'),
'&hex' => ::('&Color::Names::hex'),
'&rgb' => ::('&Color::Names::rgb'),
}
}
If I run the project with the subroutine definition above, it works:
$ perl6 --stagestats -Ilib -e 'use Color::Names "Cloford"; dd color("red")'
Stage start : 0.000
Stage parse : 0.701
Stage syntaxcheck: 0.000
Stage ast : 0.000
Stage optimize : 0.001
Stage mast : 0.006
Stage mbc : 0.000
Stage moar : 0.000
Nil
However, if I edit the sub to look like the following:
sub EXPORT(+@a) {
# cw: Implement SELECTIVE loading if necessary.
@color_list = @a.elems > 0 ??
@color_lists_found.grep(@a.any)
!!
@color_lists_found;
if $color_support {
require Color;
}
for @color_list -> $cl {
say "L: $cl";
require ::("Color::Names::{$cl}");
}
# cw: What we always export.
#
# Is there any way to get EXPORT::DEFAULT from the module block?
{
'&lists_available' => ::('&Color::Names::lists_available'),
'&lists_loaded' => ::('&Color::Names::lists_loaded'),
'&location' => ::('&Color::Names::location'),
'&color' => ::('&Color::Names::color'),
'&hex' => ::('&Color::Names::hex'),
'&rgb' => ::('&Color::Names::rgb'),
}
}
I get the following error:
$ perl6 --stagestats -Ilib -e 'use Color::Names "aa"; dd color("red")'
Stage start : 0.000
Stage parse : ===SORRY!===
Cannot find method 'merge-symbols': no method cache and no .^find_method
If you want to see this error in action, you can download the repository from here: https://github.com/Xliff/p6-color-names
So is this an error in Rakudo or an error in my code?
Thanks!