Skip to content

Commit

Permalink
Try to awesomify error for #123834
Browse files Browse the repository at this point in the history
  • Loading branch information
Mouq committed Feb 15, 2015
1 parent 0b48529 commit 6245cfb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/Perl6/Grammar.nqp
Expand Up @@ -2811,7 +2811,12 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
<post_constraint>*
[
<default_value>
[<!before <[,;)\]{}-]> > { self.typed_panic("X::Parameter::MisplacedDefault") }]?
[ <modifier=.trait> {
self.typed_panic: "X::Parameter::AfterDefault", type => "trait", modifier => $<modifier>, default => $<default_value>
}]?
[ <modifier=.post_constraint> {
self.typed_panic: "X::Parameter::AfterDefault", type => "post constraint", modifier => $<modifier>, default => $<default_value>
}]?
]**0..1

# enforce zone constraints
Expand Down
10 changes: 8 additions & 2 deletions src/core/Exception.pm
Expand Up @@ -757,8 +757,14 @@ my class X::Parameter::Default does X::Comp {
}
}

my class X::Parameter::MisplacedDefault does X::Syntax {
method message() { "Default expression must come last" }
my class X::Parameter::AfterDefault does X::Syntax {
has $.type;
has $.modifier;
has $.default;
method message() {
"The $.type \"$.modifier\" came after the default value\n"
~ "(did you mean \"...$.modifier $.default\"?)"
}
}

my class X::Parameter::Placeholder does X::Comp {
Expand Down

0 comments on commit 6245cfb

Please sign in to comment.