Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 13f2f97
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/core/Array.pm
Expand Up @@ -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]"
Expand Down
8 changes: 6 additions & 2 deletions src/core/Hash.pm
Expand Up @@ -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]";
Expand Down

0 comments on commit 13f2f97

Please sign in to comment.