Skip to content
Browse files

awesomify X::Parameter::WrongOrder and X::Parameter::MultipleTypeCons…

…traints
  • Loading branch information...
1 parent 9c318f9 commit 1e651cef80bb4f677fadc55c7b57880b06278a5f @moritz moritz committed Aug 17, 2012
Showing with 15 additions and 7 deletions.
  1. +6 −2 src/Perl6/Actions.pm
  2. +4 −3 src/Perl6/Grammar.pm
  3. +5 −2 src/core/Exception.pm
View
8 src/Perl6/Actions.pm
@@ -2947,7 +2947,9 @@ class Perl6::Actions is HLL::Actions {
}
else {
if nqp::existskey(%*PARAM_INFO, 'nominal_type') {
- $*W.throw($/, ['X', 'Parameter', 'MultipleTypeConstraints']);
+ $*W.throw($/, ['X', 'Parameter', 'MultipleTypeConstraints'],
+ parameter => (%*PARAM_INFO<variable_name> // ''),
+ );
}
my $type := $<typename>.ast;
if nqp::isconcrete($type) {
@@ -2991,7 +2993,9 @@ class Perl6::Actions is HLL::Actions {
}
elsif $<value> {
if nqp::existskey(%*PARAM_INFO, 'nominal_type') {
- $*W.throw($/, ['X', 'Parameter', 'MultipleTypeConstraints']);
+ $*W.throw($/, ['X', 'Parameter', 'MultipleTypeConstraints'],
+ parameter => (%*PARAM_INFO<variable_name> // ''),
+ );
}
my $ast := $<value>.ast;
unless $ast.has_compile_time_value {
View
7 src/Perl6/Grammar.pm
@@ -1778,20 +1778,21 @@ grammar Perl6::Grammar is HLL::Grammar {
$<quant> eq '!' ?? '!' !!
$<quant> ne '' && $<quant> ne '\\' ?? '*' !!
'!';
+ my $name := %*PARAM_INFO<variable_name> // '';
if $kind eq '!' {
if $*zone eq 'posopt' {
- $/.CURSOR.typed_panic('X::Parameter::WrongOrder', misplaced => 'required', after => 'optional');
+ $/.CURSOR.typed_panic('X::Parameter::WrongOrder', misplaced => 'required', after => 'optional', parameter => $name);
}
elsif $*zone eq 'var' {
- $/.CURSOR.typed_panic('X::Parameter::WrongOrder', misplaced => 'required', after => 'variadic');
+ $/.CURSOR.typed_panic('X::Parameter::WrongOrder', misplaced => 'required', after => 'variadic', parameter => $name);
}
}
elsif $kind eq '?' {
if $*zone eq 'posreq' {
$*zone := 'posopt';
}
elsif $*zone eq 'var' {
- $/.CURSOR.typed_panic('X::Parameter::WrongOrder', misplaced => 'optional positional', after => 'variadic');
+ $/.CURSOR.typed_panic('X::Parameter::WrongOrder', misplaced => 'optional positional', after => 'variadic', parameter => $name);
}
}
elsif $kind eq '*' {
View
7 src/core/Exception.pm
@@ -448,16 +448,19 @@ my class X::Parameter::Twigil does X::Comp {
}
my class X::Parameter::MultipleTypeConstraints does X::Comp {
+ has $.parameter;
method message() {
- "A parameter may only have on prefix type constraint";
+ ($.parameter ?? "Parameter $.parameter" !! 'A parameter')
+ ~ " may only have one prefix type constraint";
}
}
my class X::Parameter::WrongOrder does X::Comp {
has $.misplaced;
+ has $.parameter;
has $.after;
method message() {
- "Cannot put $.misplaced parameter after $.after parameters";
+ "Cannot put $.misplaced parameter $.parameter after $.after parameters";
}
}

0 comments on commit 1e651ce

Please sign in to comment.
Something went wrong with that request. Please try again.