Skip to content

Commit

Permalink
fix stringification of Any, and thus RT #73410
Browse files Browse the repository at this point in the history
Thanks to jnthn++ for helping me with this one.
  • Loading branch information
moritz committed Mar 8, 2010
1 parent df743fe commit 393fcd4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
13 changes: 13 additions & 0 deletions src/builtins/Int.pir
Expand Up @@ -69,8 +69,21 @@ Returns the identify value.
.return ($I0)
.end

=item Str()

Coercion to Str

=cut

.sub 'Str' :method
$S0 = self
$P0 = box $S0
.return ($P0)
.end

=back


=head2 Operators

=over 4
Expand Down
4 changes: 2 additions & 2 deletions src/core/Any-str.pm
Expand Up @@ -237,8 +237,8 @@ augment class Any {
$! ?? fail( "Insufficient arguments supplied to sprintf") !! $result
}

method Str() {
self
multi method Str() {
sprintf '%s<0x%f>', self.WHAT, self.WHERE;
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/core/Int.pm
Expand Up @@ -31,10 +31,6 @@ augment class Int {

our ::Complex multi method Complex() { Complex.new(self, 0); }

our Str multi method Str() {
~self;
}

# Most of the trig functions for Int are in Any-num.pm, but
# sec is a special case.
our Num multi method sec($base = Radians) {
Expand Down
2 changes: 2 additions & 0 deletions src/core/Str.pm
@@ -1,6 +1,8 @@
augment class Str {
multi method Bool { ?(pir::istrue__IP(self)); }

method Str() { self }

# CHEAT: this implementation is a bit of a cheat,
# but works fine for now.
multi method Int { (+self).Int; }
Expand Down

0 comments on commit 393fcd4

Please sign in to comment.