Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add warning on smartmatch of Match or Nil

  • Loading branch information...
commit 52fe6d207c8227c236a6bcdf445f33f302d1e413 1 parent 7551b8f
@TimToady TimToady authored
Showing with 7 additions and 5 deletions.
  1. +7 −5 STD.pm6
View
12 STD.pm6
@@ -3801,15 +3801,17 @@ grammar P6 is STD {
token dumbsmart {
[ \h*
- ('True'|'False'|'Bool::True'|'Bool::False') <?before \s>
+ ('True'|'False'|'Bool::True'|'Bool::False'|'Match'|'Nil')
{
my $litbool = $0[0].Str;
- my $true = $litbool ~~ /True/;
+ my $true = $litbool ~~ /True|Match/;
+ my $suggest =
+ $true ?? ':so or *.so or ?*' !!
+ $litbool ~~ /Nil/ ?? '* === Nil or :!defined' !!
+ ':!so or *.not or !*';
self.worry("Smartmatch against $litbool always " ~
($true ?? 'matches' !! 'fails') ~
- "; if you mean to test the topic for\n truthiness, please use " ~
- ($true ?? ':so or *.so or ?*' !! ':!so or *.not or !*') ~
- ' instead');
+ "; perhaps you should use $suggest instead");
}
]?
}
Please sign in to comment.
Something went wrong with that request. Please try again.