Skip to content

Commit f4748eb

Browse files
committed
improve message on .meth (stuff)
old message would point to the paren and say you needed parens...
1 parent fab64fc commit f4748eb

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

STD.pm6

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3167,8 +3167,8 @@ grammar P6 is STD {
31673167
if self.lineof($startpos) != self.lineof($endpos) {
31683168
.panic("Unexpected block in infix position (previous line missing its semicolon?)");
31693169
}
3170-
elsif @*MEMOS[$¢.pos-1]<baremeth> {
3171-
.panic("Unexpected block in infix position (method call needs colon or parens to take arguments)");
3170+
elsif @*MEMOS[$startpos]<baremeth> {
3171+
.cursor($startpos).panic("Unexpected block in infix position (method call with args needs colon or parens without whitespace)");
31723172
}
31733173
else {
31743174
.panic("Unexpected block in infix position (two terms in a row, or previous statement missing semicolon?)");
@@ -6101,19 +6101,19 @@ method panic (Str $s) {
61016101
$*HIGHMESS ~= $s ~ "\n";
61026102
}
61036103
6104-
$m ~= $here.locmess;
6105-
$m ~= "\n" unless $m ~~ /\n$/;
6104+
my $x;
61066105
61076106
if $highvalid and %$*HIGHEXPECT {
61086107
my @keys = sort keys %$*HIGHEXPECT;
61096108
if @keys > 1 {
6110-
$m ~= " expecting any of:\n\t" ~ join("\n\t", sort keys %$*HIGHEXPECT) ~ "\n";
6109+
$x = " expecting any of:\n\t" ~ join("\n\t", sort keys %$*HIGHEXPECT) ~ "\n";
61116110
}
61126111
else {
6113-
$m ~= " expecting @keys\n" unless @keys[0] eq 'whitespace';
6112+
$x = " expecting @keys\n" unless @keys[0] eq 'whitespace';
61146113
}
61156114
}
6116-
if $m ~~ /infix|nofun/ and not $m ~~ /regex/ and not $m ~~ /infix_circumfix/ {
6115+
6116+
if $x ~~ /infix|nofun/ and not $x ~~ /regex/ and not $x ~~ /infix_circumfix/ {
61176117
my @t = $here.suppose( sub { $here.term } );
61186118
if @t {
61196119
my $endpos = $here.pos;
@@ -6122,13 +6122,14 @@ method panic (Str $s) {
61226122
if self.lineof($startpos) != self.lineof($endpos) {
61236123
$m ~~ s|Confused|Two terms in a row (previous line missing its semicolon?)|;
61246124
}
6125-
elsif @*MEMOS[$here.pos]<listop> {
6125+
elsif @*MEMOS[$startpos]<listop> {
61266126
$m ~~ s|Confused|Two terms in a row (listop with args requires whitespace or parens)|;
61276127
}
6128-
elsif @*MEMOS[$here.pos - 1]<baremeth> {
6129-
$m ~~ s|Confused|Two terms in a row (method call requires colon or parens to take arguments)|;
6128+
elsif @*MEMOS[$startpos]<baremeth> {
6129+
$here = $here.cursor($startpos);
6130+
$m ~~ s|Confused|Two terms in a row (method call with args requires colon or parens without whitespace)|;
61306131
}
6131-
elsif @*MEMOS[$here.pos - 1]<arraycomp> {
6132+
elsif @*MEMOS[$startpos]<arraycomp> {
61326133
$m ~~ s|Confused|Two terms in a row (preceding is not a valid reduce operator)|;
61336134
}
61346135
else {
@@ -6152,6 +6153,10 @@ method panic (Str $s) {
61526153
$m ~~ s|Malformed block|Return type $type is not allowed between '$d' and '$name'; please put it:\n after the $s but before the '$d',\n within the signature following the '-->' marker, or\n as the argument of a 'returns' trait after the signature.|;
61536154
}
61546155
6156+
$m ~= $here.locmess;
6157+
$m ~= "\n" unless $m ~~ /\n$/;
6158+
$m ~= $x;
6159+
61556160
if @*WORRIES {
61566161
$m ~= "Other potential difficulties:\n " ~ join( "\n ", @*WORRIES) ~ "\n";
61576162
}

0 commit comments

Comments
 (0)