Permalink
Browse files

typed exception for symbol lookup failure

  • Loading branch information...
1 parent 321d57b commit ebc730c2492e08fd60f705c1a914c54fc8fa1da2 @moritz moritz committed Oct 5, 2012
Showing with 7 additions and 2 deletions.
  1. +5 −0 src/core/Exception.pm
  2. +2 −2 src/core/operators.pm
@@ -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;
@@ -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;

0 comments on commit ebc730c

Please sign in to comment.