Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[v6] Fix Match leak in trait_mod:of
  • Loading branch information
sorear committed Nov 17, 2010
1 parent 3392666 commit 08c9807
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/JSYNC.cs
Expand Up @@ -4,6 +4,8 @@
using System.Text;

public class JsyncWriter {
static bool FailSoft =
Environment.GetEnvironmentVariable("NIECZA_JSYNC_WRITER_FAILSOFT") != null;
StringBuilder o = new StringBuilder();
Dictionary<object,int> anchors = new Dictionary<object,int>();
int nextanchor = 0;
Expand Down Expand Up @@ -83,6 +85,11 @@ public class JsyncWriter {
}

void WriteGeneral(IP6 obj) {
if (FailSoft && !(obj is DynObject)) {
o.AppendFormat("\"UNSERIALIZABLE {0}\"", obj.mo.name);
return;
}

int a = nextanchor++;
anchors[obj] = a;
DynObject dyo = (DynObject) obj;
Expand Down
30 changes: 30 additions & 0 deletions v6/tryfile
Expand Up @@ -56,6 +56,31 @@ augment class Hash {

augment class STD {
our $ALL;
method gettrait($traitname,$param) {
my $text;
my $M;
if @$param {
$text = $param.[0].Str;
_subst($M, $text, /^\<(.*)\>$/, { $M[0] }) or
_subst($M, $text, /^\((.*)\)$/, { $M[0] });
}
if ($traitname eq 'export') {
if (defined $text) {
while _subst($M, $text, /\:/, "") { }
}
else {
$text = 'DEFAULT';
}
self.set_export($text);
$text;
}
elsif (defined $text) {
$text;
}
else {
1;
}
}
method find_stash ($n, $crlex = $*CURLEX) {
my $name = $n;
my $curlex = $crlex;
Expand Down Expand Up @@ -176,6 +201,11 @@ method do_import_aliases($pkg, *@names) {
augment class STD::P6 {
my %term = (:dba('term') , :prec<z=>);
my %methodcall = (:dba('methodcall') , :prec<y=>, :assoc<unary>, :uassoc<left>, :fiddly, :!pure);
token trait_mod:of {
['of'|'returns']:s <typename>
[ <?{ $*DECLARAND<of> }> <.sorry("Extra 'of' type; already declared as type " ~ $*DECLARAND<of>.Str)> ]?
{ $*DECLARAND<of> = $<typename>.Str; }
}
token dotty:sym<.*> {
('.' [ <[+*?=]> | '^' '!'? ]) :: <.unspacey> <dottyop>
$<sym> = {$0.Str}
Expand Down

0 comments on commit 08c9807

Please sign in to comment.