Skip to content

Commit 3c2fb9c

Browse files
committed
obs updates; move ident checks to explain_mystery
Obsolescence messages based on identifiers now done from explain_mystery so that user-defined subs of the same name aren't impacted. Added messages for new P5 regex modifiers, qr, local, and new (as function call).
1 parent 1ad3292 commit 3c2fb9c

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

STD.pm6

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,10 +1527,6 @@ grammar P6 is STD {
15271527
<xblock>
15281528
}
15291529

1530-
token statement_control:foreach {
1531-
<sym> <.obs("'foreach'", "'for'")>
1532-
}
1533-
15341530
token statement_control:given {
15351531
<sym> :s
15361532
<xblock>
@@ -2688,17 +2684,9 @@ grammar P6 is STD {
26882684
<!old_tr_mods>
26892685
}
26902686

2691-
token quote:y {
2692-
<sym> »
2693-
# could be defined as a function or constant
2694-
<!{ self.is_known('&y') or self.is_known('y') }>
2695-
<!before '('> <?before \h*\W>
2696-
<.obs('y///','tr///')>
2697-
}
2698-
26992687
token old_rx_mods {
27002688
<!after \s>
2701-
(< i g s m x c e >+)
2689+
(\w+)
27022690
{
27032691
given $0.Str {
27042692
$_ ~~ /i/ and.worryobs('/i',':i');
@@ -2708,6 +2696,12 @@ grammar P6 is STD {
27082696
$_ ~~ /x/ and.worryobs('/x','normal default whitespace');
27092697
$_ ~~ /c/ and.worryobs('/c',':c or :p');
27102698
$_ ~~ /e/ and.worryobs('/e','interpolated {...} or s{} = ... form');
2699+
$_ ~~ /r/ and.worryobs('/c','.subst');
2700+
$_ ~~ /a/ and.worryobs('/a','Unicode');
2701+
$_ ~~ /d/ and.worryobs('/d','Unicode');
2702+
$_ ~~ /l/ and.worryobs('/l','Unicode');
2703+
$_ ~~ /u/ and.worryobs('/l','normal regex');
2704+
$_ ~~ /p/ and.worryobs('/c','substr or /$<PREMATCH>=[...] <(...)> $<POSTMATCH>=[...]');
27112705
.obs('suffix regex modifiers','prefix adverbs');
27122706
}
27132707
}
@@ -3103,11 +3097,6 @@ grammar P6 is STD {
31033097
<O(|%term)>
31043098
}
31053099

3106-
token term:sym<Object> {
3107-
<sym> » {}
3108-
<.obs('Object', 'Mu as the "most universal" object type')>
3109-
}
3110-
31113100
token term:sym<undef> {
31123101
<sym> » {}
31133102
[ <?before \h*'$/' >
@@ -5732,13 +5721,22 @@ method explain_mystery() {
57325721
$m ~= "Undeclared name" ~ ('s' x (@tmp != 1)) ~ ":\n";
57335722
for @tmp {
57345723
$m ~= "\t'$_' used at line " ~ %unk_types{$_}.<line> ~ "\n";
5724+
$m ~= "\t (in Perl 6 please use Mu as the most universal type)\n" if $_ eq 'Object';
57355725
}
57365726
}
57375727
if %unk_routines {
57385728
my @tmp = sort keys(%unk_routines);
57395729
$m ~= "Undeclared routine" ~ ('s' x (@tmp != 1)) ~ ":\n";
5730+
my $obs = {
5731+
y => "tr",
5732+
qr => "rx",
5733+
local => "temp (or dynamic var)",
5734+
new => "method call syntax",
5735+
foreach => "for",
5736+
}
57405737
for @tmp {
57415738
$m ~= "\t'$_' used at line " ~ %unk_routines{$_}.<line> ~ "\n";
5739+
$m ~= "\t (in Perl 6 please use " ~ $obs{$_} ~ " instead)\n" if $obs{$_};
57425740
}
57435741
}
57445742
self.sorry($m) if $m;

0 commit comments

Comments
 (0)