It seems that a a sub cannot access dynamic variables when it is used inside a map and that map is "return"ed.
Consider this piece of code:
sub start {
    my $*something = 'foobar';
    
    # WORKS
    say 'first say-something:';
    say-something;
    
    # WORKS
    say 'mapped say-something, no return:';
    my @foo = (^2).map({say-something});
    
    # ERROR: Dynamic variable $*something not found
    say 'mapped say-something, with return:';
    return (^2).map({say-something});
}
sub say-something {
    say $*something;
    1
}
start;
This will output:
first say-something:
foobar
mapped say-something, no return:
foobar
foobar
mapped say-something, with return:
Dynamic variable $*something not found
  in sub say-something at main.raku line 18
  in block <unit> at main.raku line 14
Why can't the sub access the dynamic variable? Is there a workaround for this?
 
    