Skip to content

Instantly share code, notes, and snippets.

@tadzik
Created July 8, 2011 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tadzik/1071441 to your computer and use it in GitHub Desktop.
Save tadzik/1071441 to your computer and use it in GitHub Desktop.
Segmentation fun
┌─[tadzik@yavin4]─[~/src/nom] (podparser)
└─[%]─> g diff | cat
diff --git a/src/core/Mu.pm b/src/core/Mu.pm
index 4e89251..e3cbb0f 100644
--- a/src/core/Mu.pm
+++ b/src/core/Mu.pm
@@ -106,8 +106,17 @@ my class Mu {
multi method gist(Mu:D:) { self.Stringy }
proto method perl(|$) { * }
- multi method perl(Mu:D:) { self.Str }
multi method perl(Mu:U:) { self.HOW.name(self) }
+ multi method perl(Mu:D:) {
+ my $type = self.HOW.name(self);
+ $type ~ '.new(' ~ self.^attributes.map({
+ substr($_.name, 2, nqp::chars($_.name))
+ ~ ' => '
+ ~ nqp::getattr(
+ pir::perl6_decontainerize__PP(self), $type, $_.name
+ ).perl
+ }).join(',') ~ ')';
+ }
proto method DUMP(|$) { * }
multi method DUMP(Mu:D:) { self.perl }
┌─[tadzik@yavin4]─[~/src/nom] (podparser)
└─[%]─> ./perl6 -e 'class A { has $.a }; my $a = A.new(a => 7); $a.perl.say'
zsh: segmentation fault ./perl6 -e 'class A { has $.a }; my $a = A.new(a => 7); $a.perl.say'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment