Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Good error for unexpected closing bracket.
  • Loading branch information
jnthn committed Dec 10, 2012
1 parent c5e946f commit b9b110b
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/Perl6/World.pm
Expand Up @@ -2025,21 +2025,28 @@ class Perl6::World is HLL::World {
}

# Try and better explain "Confused".
my @locprepost := self.locprepost($c);
if $ex.HOW.name($ex) eq 'X::Syntax::Confused' {
my $expected_infix := 0;
for @expected {
if nqp::index($_, "infix") >= 0 {
$expected_infix := 1;
last;
}
my $next := nqp::substr(@locprepost[1], 0, 1);
if $next ~~ /\)|\]|\}|/ {
%opts<reason> := "Unexpected closing bracket";
@expected := [];
}
if $expected_infix {
%opts<reason> := "Two terms in a row";
else {
my $expected_infix := 0;
for @expected {
if nqp::index($_, "infix") >= 0 {
$expected_infix := 1;
last;
}
}
if $expected_infix {
%opts<reason> := "Two terms in a row";
}
}
}

# Build and throw exception object.
my @locprepost := self.locprepost($c);
%opts<line> := HLL::Compiler.lineof($c.orig, $c.pos);
%opts<modules> := p6ize_recursive(@*MODULES);
%opts<pre> := @locprepost[0];
Expand Down

0 comments on commit b9b110b

Please sign in to comment.