Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
typed exceptions for things that must be known at compile time
  • Loading branch information
moritz committed Feb 8, 2012
1 parent 6ed624d commit a2792b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Perl6/Actions.pm
Expand Up @@ -2058,7 +2058,7 @@ class Perl6::Actions is HLL::Actions {
@values.push($_);
}
else {
$<term>.CURSOR.panic("Enumeration values must be known at compile time");
$*W.throw($<term>, ['X', 'Value', 'Dynamic'], what => 'Enumeration');
}
}
}
Expand All @@ -2069,7 +2069,7 @@ class Perl6::Actions is HLL::Actions {
@values.push($term_ast);
}
else {
$<term>.CURSOR.panic("Enumeration values must be known or constant-foldable at compile time");
$*W.throw($<term>, ['X', 'Value', 'Dynamic'], what => 'Enumeration');
}

# Now we have them, we can go about computing the value
Expand All @@ -2096,7 +2096,7 @@ class Perl6::Actions is HLL::Actions {
$ok := 1;
}
unless $ok {
$/.CURSOR.panic("Enumeration values must be known or constant-foldable at compile time");
$*W.throw($/, ['X', 'Value', 'Dynamic'], what => 'Enumeration');
}
}
}
Expand Down Expand Up @@ -3823,7 +3823,7 @@ class Perl6::Actions is HLL::Actions {
}
else {
if %SHARED_ALLOWED_ADVERBS{$key} {
$/.CURSOR.panic('Value of adverb :' ~ $key ~ ' must be known at compile time');
$*W.throw($/, ['X', 'Value', 'Dynamic'], what => "Adverb $key");
}
}
%*RX{$key} := $value;
Expand Down Expand Up @@ -4539,7 +4539,7 @@ class Perl6::Actions is HLL::Actions {
nqp::unbox_s($past<compile_time_value>);
}
else {
$/.CURSOR.panic("$usage must have a value known at compile time");
$*W.throw($/, ['X', 'Value', 'Dynamic'], what => $usage);
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/core/Exceptions.pm
Expand Up @@ -189,6 +189,11 @@ my class X::Bind::NativeType does X::Comp {
}
}

my class X::Value::Dynamic does X::Comp {
has $.what;
method message() { "$.what value must be known at compile time" }
}

my class X::Syntax::Name::Null does X::Syntax {
method message() { 'Name component my not be null'; }
}
Expand Down

0 comments on commit a2792b9

Please sign in to comment.