Skip to content

Commit

Permalink
Fix "class A is B{}" LTA error
Browse files Browse the repository at this point in the history
Partial fix to R#2052
  • Loading branch information
lizmat committed Jul 12, 2018
1 parent 8f09082 commit 1956df2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/Exception.pm6
Expand Up @@ -1389,6 +1389,14 @@ my class X::Syntax::KeywordAsFunction does X::Syntax {
}
}

my class X::Syntax::ParentAsHash does X::Syntax {
has $.parent;
method message() {
"Syntax error while specifying a parent class:\n"
~ "Must specify a space between {$.parent.^name} and \{";
}
}

my class X::Syntax::Malformed::Elsif does X::Syntax {
has $.what = 'else if';
method message() { qq{In Perl 6, please use "elsif' instead of "$.what"} }
Expand Down
4 changes: 4 additions & 0 deletions src/core/traits.pm6
@@ -1,4 +1,5 @@
# for errors
my class X::Syntax::ParentAsHash { ... }
my class X::Inheritance::Unsupported { ... }
my class X::Inheritance::UnknownParent { ... }
my class X::Export::NameClash { ... }
Expand Down Expand Up @@ -59,6 +60,9 @@ multi sub trait_mod:<is>(Mu:U $type, :$hidden!) {
multi sub trait_mod:<is>(Mu:U $type, Mu :$array_type!) {
$type.^set_array_type($array_type);
}
multi sub trait_mod:<is>(Mu:U $type, Mu:U $parent, Hash) {
X::Syntax::ParentAsHash.new(:$parent).throw;
}
multi sub trait_mod:<is>(Mu:U $type, *%fail) {
if %fail.keys[0] !eq $type.^name {
X::Inheritance::UnknownParent.new(
Expand Down

0 comments on commit 1956df2

Please sign in to comment.