Permalink
Browse files

report parameter name in X::Parameter::Default

  • Loading branch information...
1 parent 13fee9c commit 9c318f91b7668adb323c9353ca0df61ab3fa40f8 @moritz moritz committed Aug 17, 2012
Showing with 11 additions and 3 deletions.
  1. +5 −2 src/Perl6/Actions.pm
  2. +6 −1 src/core/Exception.pm
View
@@ -2774,11 +2774,14 @@ class Perl6::Actions is HLL::Actions {
# Sanity checks.
my $quant := $<quant>;
if $<default_value> {
+ my $name := %*PARAM_INFO<variable_name> // '';
if $quant eq '*' {
- $*W.throw($/, ['X', 'Parameter', 'Default'], how => 'slurpy');
+ $*W.throw($/, ['X', 'Parameter', 'Default'], how => 'slurpy',
+ parameter => $name);
}
if $quant eq '!' {
- $*W.throw($/, ['X', 'Parameter', 'Default'], how => 'required');
+ $*W.throw($/, ['X', 'Parameter', 'Default'], how => 'required',
+ parameter => $name);
}
my $val := $<default_value>[0].ast;
if $val.has_compile_time_value {
View
@@ -422,7 +422,12 @@ my class X::Obsolete does X::Comp {
my class X::Parameter::Default does X::Comp {
has $.how;
- method message() { "Cannot put default on $.how parameter" };
+ has $.parameter;
+ method message() {
+ $.parameter
+ ?? "Cannot put default on $.how parameter $.parameter"
+ !! "Cannot put default on anonymous $.how parameter";
+ }
}
my class X::Parameter::Placeholder does X::Comp {

0 comments on commit 9c318f9

Please sign in to comment.