Skip to content

Commit

Permalink
typed exception for symbol lookup failure
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Oct 5, 2012
1 parent 321d57b commit ebc730c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/core/Exception.pm
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,11 @@ my class X::PseudoPackage::InDeclaration does X::Comp {
}
}

my class X::NoSuchSymbol is Exception {
has $.symbol;
method message { "No such symbol '$.symbol'" }
}


{
my %c_ex;
Expand Down
4 changes: 2 additions & 2 deletions src/core/operators.pm
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ sub INDIRECT_NAME_LOOKUP($root, *@chunks) is rw {
}
my Mu $thing := $root.exists($first) ?? $root{$first} !!
GLOBAL::.exists($first) ?? GLOBAL::{$first} !!
fail("Symbol '$name' not found");
X::NoSuchSymbol.new(symbol => $name).fail;
for @parts {
fail("Symbol '$name not found") unless $thing.WHO.exists($_);
X::NoSuchSymbol(symbol => $name).fail unless $thing.WHO.exists($_);
$thing := $thing.WHO{$_};
}
$thing;
Expand Down

0 comments on commit ebc730c

Please sign in to comment.