-
-
Save FROGGS/d1b09046bed6dd01ab56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/core/traits.pm b/src/core/traits.pm | |
index c0e961a..e4d70fe 100644 | |
--- a/src/core/traits.pm | |
+++ b/src/core/traits.pm | |
@@ -187,6 +187,18 @@ multi sub trait_mod:<is>(Routine $r, :&tighter!) { | |
} | |
$r.prec<prec> := $r.prec<prec>.subst(/\=/, '@='); | |
$r.prec<assoc>:delete; | |
+ if $r.prec<prec> le 'w=' { | |
+ my $name := $r.name; | |
+ if $name.starts-with('prefix:') { | |
+ die 'Precedence of a prefix must be tighter then any infix' | |
+ } | |
+ elsif $name.starts-with('postfix:') { | |
+ die 'Precedence of a postfix must be tighter then any infix' | |
+ } | |
+ elsif $name.starts-with('postcircumfix:') { | |
+ die 'Precedence of a postcircumfix must be tighter then any infix' | |
+ } | |
+ } | |
} | |
multi sub trait_mod:<is>(Routine $r, :&looser!) { | |
die "Routine given to looser does not appear to be an operator" | |
@@ -196,6 +208,18 @@ multi sub trait_mod:<is>(Routine $r, :&looser!) { | |
} | |
$r.prec<prec> := $r.prec<prec>.subst(/\=/, ':='); | |
$r.prec<assoc>:delete; | |
+ if $r.prec<prec> le 'w=' { | |
+ my $name := $r.name; | |
+ if $name.starts-with('prefix:') { | |
+ die 'Precedence of a prefix must be tighter then any infix' | |
+ } | |
+ elsif $name.starts-with('postfix:') { | |
+ die 'Precedence of a postfix must be tighter then any infix' | |
+ } | |
+ elsif $name.starts-with('postcircumfix:') { | |
+ die 'Precedence of a postcircumfix must be tighter then any infix' | |
+ } | |
+ } | |
} | |
multi sub trait_mod:<is>(Routine $r, :$assoc!) { | |
trait_mod:<is>($r, :prec({ :$assoc })) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment