Skip to content

Commit

Permalink
Fix 'is export' on constants assigned to routines
Browse files Browse the repository at this point in the history
The 'is export' exception catchall was higher precedence than the
constant exporting candidate in the case of Routine. This patch makes
`constant $sub is export = sub { ... }` take the same path as
`sub foo is export { ... }` while preserving the constant variable's
symbol.

Fixes "Can't use unknown trait 'is export' in a ... declaration" for
statements like:

constant $constant-regex is export =  /fo*/;
constant &constant-sub   is export  = sub { "win" };

Zoffix++ for the patch
  • Loading branch information
LLFourn committed Jul 6, 2017
1 parent 15a9338 commit d067abf
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/core/traits.pm
Expand Up @@ -251,13 +251,12 @@ my $!;
my $/;
my $_;

multi sub trait_mod:<is>(Routine:D \r, :$export!) {
multi sub trait_mod:<is>(Routine:D \r, :$export!, :$SYMBOL = '&' ~ r.name) {
my $to_export := r.multi ?? r.dispatcher !! r;
my $exp_name := '&' ~ r.name;
my @tags = flat 'ALL', (nqp::istype($export,Pair) ?? $export.key() !!
nqp::istype($export,Positional) ?? @($export)>>.key !!
'DEFAULT');
Rakudo::Internals.EXPORT_SYMBOL($exp_name, @tags, $to_export);
Rakudo::Internals.EXPORT_SYMBOL(nqp::decont($SYMBOL), @tags, $to_export);
}
multi sub trait_mod:<is>(Mu:U \type, :$export!) {
my $exp_name := type.^shortname;
Expand Down

0 comments on commit d067abf

Please sign in to comment.