Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Throw Inheritance::SelfInherit. #97

Closed
wants to merge 1 commit into from

1 participant

@timo
Collaborator

Passes all spectests (including one added for this specific throw.)

@timo timo closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 19, 2013
  1. @timo

    Throw Inheritance::SelfInherit.

    timo authored
This page is out of date. Refresh to see the latest.
Showing with 20 additions and 5 deletions.
  1. +8 −0 src/core/Exception.pm
  2. +12 −5 src/core/traits.pm
View
8 src/core/Exception.pm
@@ -1066,6 +1066,14 @@ my class X::Inheritance::UnknownParent is Exception {
}
}
+my class X::Inheritance::SelfInherit is Exception {
+ has $.name;
+
+ method message {
+ "'$.name' cannot inherit from itself."
+ }
+}
+
my class X::Export::NameClash does X::Comp {
has $.symbol;
method message() {
View
17 src/core/traits.pm
@@ -17,6 +17,7 @@ my class X::Export::NameClash { ... }
my class X::Composition::NotComposable { ... }
my class X::Import::MissingSymbols { ... }
my class X::Redeclaration { ... }
+my class X::Inheritance::SelfInherit { ... }
proto trait_mod:<is>(|) { * }
multi trait_mod:<is>(Mu:U $child, Mu:U $parent) {
@@ -43,11 +44,17 @@ multi trait_mod:<is>(Mu:U $type, :$hidden!) {
$type.HOW.set_hidden($type);
}
multi trait_mod:<is>(Mu:U $type, *%fail) {
- X::Inheritance::UnknownParent.new(
- :child($type.HOW.name($type)),
- :parent(%fail.keys[0]),
- :suggestions([])
- ).throw;
+ if %fail.keys[0] !eq $type.HOW.name($type) {
+ X::Inheritance::UnknownParent.new(
+ :child($type.HOW.name($type)),
+ :parent(%fail.keys[0]),
+ :suggestions([])
+ ).throw;
+ } else {
+ X::Inheritance::SelfInherit.new(
+ :name(%fail.keys[0])
+ ).throw;
+ }
}
multi trait_mod:<is>(Attribute:D $attr, :$rw!) {
Something went wrong with that request. Please try again.