Skip to content

Commit

Permalink
Make .WHAT return something more sensible for arrays/hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Aug 19, 2013
1 parent 8f64f1e commit e6419ae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/core/Array.pm
Expand Up @@ -185,7 +185,8 @@ class Array { # declared in BOOTSTRAP
method PARAMETERIZE_TYPE(Mu $t, |c) {
if c.elems == 0 {
my $what := self but TypedArray[$t.WHAT];
$what.HOW.set_name(self, "Array[{$t.HOW.name(self)}]");
# needs to be done in COMPOSE phaser when that works
$what.HOW.set_name(self,"{self.HOW.name(self)}[{$t.HOW.name($t)}]");
$what;
}
else {
Expand Down
6 changes: 4 additions & 2 deletions src/core/Hash.pm
Expand Up @@ -347,12 +347,14 @@ my class Hash { # declared in BOOTSTRAP
method PARAMETERIZE_TYPE(Mu $t, |c) {
if c.elems == 0 {
my $what := self but TypedHash[$t.WHAT];
$what.HOW.set_name(self, "Hash[{$t.HOW.name(self)}]");
# needs to be done in COMPOSE phaser when that works
$what.HOW.set_name(self,"{self.HOW.name(self)}[{$t.HOW.name($t)}]");
$what;
}
elsif c.elems == 1 {
my $what := self but TypedHash[$t.WHAT, c[0]];
$what.HOW.set_name(self, "Hash[{$t.HOW.name(self)},{c[0].HOW.name(self)}]");
# needs to be done in COMPOSE phaser when that works
$what.HOW.set_name(self,"{self.HOW.name(self)}[{$t.HOW.name($t)},{c[0].HOW.name(c[0])}]");
$what;
}
else {
Expand Down
5 changes: 4 additions & 1 deletion src/core/Variable.pm
Expand Up @@ -65,11 +65,14 @@ multi trait_mod:<of>(Variable:D $v, |c ) {
multi trait_mod:<of>(Variable:D $v, Mu:U $of ) {
my $var := $v.var;
my $what := $var.VAR.WHAT;
my $how := $what.HOW;
nqp::getattr(
$var,
$what.HOW.mixin_base($what),
$how.mixin_base($what),
'$!descriptor'
).set_of(nqp::decont($of));
# probably can go if we have a COMPOSE phaser for PARAMETERIZE
$how.set_name($what,"{$how.name($what)}[{$of.HOW.name($of)}]");
}

# phaser traits
Expand Down

0 comments on commit e6419ae

Please sign in to comment.