Skip to content

Commit

Permalink
Make sure if we have a sub foo(Foo $x?) { } then $x default to a Foo …
Browse files Browse the repository at this point in the history
…type object, not Any.
  • Loading branch information
jnthn committed Jul 4, 2010
1 parent 5c25692 commit 067b67f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/binder/bind.c
Expand Up @@ -438,6 +438,10 @@ Rakudo_binding_handle_optional(PARROT_INTERP, llsig_element *sig_info, PMC *lexp
/* Did the value already get initialized to something? (We can avoid re-creating a
* PMC if so.) */
else if (!PMC_IS_NULL(cur_lex = VTABLE_get_pmc_keyed_str(interp, lexpad, sig_info->variable_name))) {
/* Yes; if $ sigil then we want to bind set value in it to be the
* type object of the default type. */
if (!(sig_info->flags & (SIG_ELEM_ARRAY_SIGIL | SIG_ELEM_HASH_SIGIL)))
VTABLE_set_pmc(interp, cur_lex, sig_info->nominal_type);
return cur_lex;
}

Expand All @@ -450,7 +454,7 @@ Rakudo_binding_handle_optional(PARROT_INTERP, llsig_element *sig_info, PMC *lexp
return Rakudo_binding_create_hash(interp, pmc_new(interp, enum_class_Hash));
}
else {
return pmc_new(interp, pmc_type(interp, string_from_literal(interp, "Perl6Scalar")));
return pmc_new_init(interp, pmc_type(interp, string_from_literal(interp, "Perl6Scalar")), sig_info->nominal_type);
}
}
}
Expand Down

0 comments on commit 067b67f

Please sign in to comment.