Skip to content

Commit

Permalink
Various corrections to handling of where clauses and type captures, w…
Browse files Browse the repository at this point in the history
…hich was the main issue we faced in getting us doing most of S06-multi/type-based.t again.
  • Loading branch information
jnthn committed Feb 16, 2010
1 parent 9267d1e commit 8d9598e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
11 changes: 10 additions & 1 deletion src/Perl6/Compiler/Parameter.pm
Expand Up @@ -86,7 +86,16 @@ method default_from_outer($default_from_outer?) {
}

method nom_type($nom_type?) {
if $nom_type { $!nom_type := $nom_type }
if $nom_type {
if $nom_type.isa(PAST::Op) && $nom_type.name() eq 'new' {
# It's a thunk (cretion of a new code block); we'll make this
# a constraint.
self.cons_types.push($nom_type)
}
else {
$!nom_type := $nom_type
}
}
$!nom_type
}

Expand Down
6 changes: 3 additions & 3 deletions src/Perl6/Compiler/Signature.pm
Expand Up @@ -232,16 +232,16 @@ method ast($high_level?) {
:scope('package')
);
}
else {
else {
$nom_type := $_.nom_type;
}
}
}
elsif $_.sigil ne "" && !$_.invocant {
# May well be a parametric role based type.
my $role_name;
if $_.sigil eq "@" { $role_name := "Positional" }
elsif $_.sigil eq "%" { $role_name := "Associative" }
elsif $_.sigil ne ":" { $role_name := "Callable" }
elsif $_.sigil eq "&" { $role_name := "Callable" }
if $role_name {
my $role_type := PAST::Var.new( :name($role_name), :namespace(''), :scope('package') );
if !$_.nom_type {
Expand Down
5 changes: 3 additions & 2 deletions src/binder/bind.c
Expand Up @@ -311,8 +311,9 @@ Rakudo_binding_bind_one_param(PARROT_INTERP, PMC *lexpad, llsig_element *sig_inf
for (i = 0; i < num_constraints; i++) {
PMC *cons_type = VTABLE_get_pmc_keyed_int(interp, constraints, i);
PMC *accepts_meth = VTABLE_find_method(interp, cons_type, ACCEPTS);
if (VTABLE_isa(interp, cons_type, string_from_literal(interp, "Sub")))
Parrot_capture_lex(interp, cons_type);
if (VTABLE_isa(interp, cons_type, string_from_literal(interp, "Block")))
Parrot_capture_lex(interp, VTABLE_get_attr_str(interp, cons_type,
string_from_literal(interp, "$!do")));
Parrot_ext_call(interp, accepts_meth, "PiP->P", cons_type, value, &result);
if (!VTABLE_get_bool(interp, result)) {
if (error)
Expand Down

0 comments on commit 8d9598e

Please sign in to comment.