Permalink
Browse files

Make (Array|Hash).WHAT return something sensible for specifically typ…

…ed case

jnthn++, TimToady++ for guidance
  • Loading branch information...
lizmat committed Aug 19, 2013
1 parent da63d08 commit 13f2f970c2913917d7126929e6591dc47c1ece3c
Showing with 9 additions and 3 deletions.
  1. +3 −1 src/core/Array.pm
  2. +6 −2 src/core/Hash.pm
View
@@ -184,7 +184,9 @@ class Array { # declared in BOOTSTRAP
}
method PARAMETERIZE_TYPE(Mu $t, |c) {
if c.elems == 0 {
- self but TypedArray[$t.WHAT]
+ my $what := self but TypedArray[$t.WHAT];
+ $what.HOW.set_name(self, "Array[{$t.HOW.name(self)}]");
+ $what;
}
else {
die "Can only type-constraint Array with [ValueType]"
View
@@ -346,10 +346,14 @@ my class Hash { # declared in BOOTSTRAP
}
method PARAMETERIZE_TYPE(Mu $t, |c) {
if c.elems == 0 {
- self but TypedHash[$t.WHAT]
+ my $what := self but TypedHash[$t.WHAT];
+ $what.HOW.set_name(self, "Hash[{$t.HOW.name(self)}]");
+ $what;
}
elsif c.elems == 1 {
- self but TypedHash[$t.WHAT, c[0]]
+ my $what := self but TypedHash[$t.WHAT, c[0]];
+ $what.HOW.set_name(self, "Hash[{$t.HOW.name(self)},{c[0].HOW.name(self)}]");
+ $what;
}
else {
die "Can only type-constraint Hash with [ValueType] or [ValueType,KeyType]";

0 comments on commit 13f2f97

Please sign in to comment.