From 95f97e4e7e6cc3d09081b31dec82defe189ebc64 Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Mon, 23 Jan 2012 21:59:14 +0100 Subject: [PATCH] first X::Parameter class; many more to come... --- src/Perl6/Actions.pm | 4 ++-- src/core/Exceptions.pm | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Perl6/Actions.pm b/src/Perl6/Actions.pm index 2cec01e5e33..be11ca71fb1 100644 --- a/src/Perl6/Actions.pm +++ b/src/Perl6/Actions.pm @@ -2248,10 +2248,10 @@ class Perl6::Actions is HLL::Actions { my $quant := $; if $ { if $quant eq '*' { - $/.CURSOR.panic("Cannot put default on slurpy parameter"); + $*W.throw($/, ['X', 'Parameter', 'Default'], how => p6box_s('slurpy')); } if $quant eq '!' { - $/.CURSOR.panic("Cannot put default on required parameter"); + $*W.throw($/, ['X', 'Parameter', 'Default'], how => p6box_s('required')); } my $val := $[0].ast; if $val { diff --git a/src/core/Exceptions.pm b/src/core/Exceptions.pm index b36b07550ef..80bb19c106e 100644 --- a/src/core/Exceptions.pm +++ b/src/core/Exceptions.pm @@ -86,3 +86,8 @@ my class X::Obsolete does X::Comp { has $.when = 'in Perl 6'; method message() { "Unsupported use of $.old; $.when please use $.new" } } + +my class X::Parameter::Default does X::Comp { + has $.how; + method message() { "Cannot put default on $.how parameter" }; +}