Permalink
Browse files

typed exceptions for errors from has_self branch

  • Loading branch information...
1 parent 20cae50 commit 1733c1f1e37f66c8da234c7775f4dc2387aa7e47 @moritz moritz committed Feb 11, 2012
Showing with 11 additions and 3 deletions.
  1. +3 −3 src/Perl6/Actions.pm
  2. +8 −0 src/core/Exceptions.pm
View
@@ -1094,7 +1094,7 @@ class Perl6::Actions is HLL::Actions {
# In a declaration, don't produce anything here.
if $*IN_DECL ne 'variable' {
unless $*HAS_SELF {
- $/.CURSOR.panic("Variable $name used where no 'self' is available");
+ $*W.throw($/, ['X', 'Syntax', 'NoSelf'], variable => $name);
}
my $attr := get_attribute_meta_object($/, $name);
$past.scope('attribute_6model');
@@ -1106,9 +1106,9 @@ class Perl6::Actions is HLL::Actions {
}
elsif $twigil eq '.' && $*IN_DECL ne 'variable' {
if !$*HAS_SELF {
- $/.CURSOR.panic("Variable $name used where no 'self' available");
+ $*W.throw($/, ['X', 'Syntax', 'NoSelf'], variable => $name);
} elsif $*HAS_SELF eq 'partial' {
- $/.CURSOR.panic("Virtual call $name may not be used on partially constructed objects");
+ $*W.throw($/, ['X', 'Syntax', 'VirtualCall'], call => $name);
}
# Need to transform this to a method call.
$past := $<arglist> ?? $<arglist>[0].ast !! PAST::Op.new();
View
@@ -249,3 +249,11 @@ my class X::Syntax::SigilWithoutName does X::Syntax {
my class X::Syntax::Self::WithoutObject does X::Syntax {
method message() { "'self' used where no object is available" }
}
+my class X::Syntax::VirtualCall does X::Syntax {
+ has $.call;
+ method message() { "Virtual call $.call may not be used on partially constructed objects" }
+}
+my class X::Syntax::NoSelf does X::Syntax {
+ has $.variable;
+ method message() { "Variable $.variable used where no 'self' is available" }
+}

0 comments on commit 1733c1f

Please sign in to comment.