Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix a bug in the binder related to unboxing to native types. Also add…
… a just-in-case check for something that should 'never happen'.
  • Loading branch information
jnthn committed Oct 25, 2011
1 parent 9897b01 commit 3fb9155
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/binder/bind.c
Expand Up @@ -313,12 +313,14 @@ Rakudo_binding_bind_one_param(PARROT_INTERP, PMC *lexpad, Rakudo_Signature *sign
bv.val.o = create_box(interp, orig_bv);
}
else {
storage_spec spec = REPR(orig_bv.val.o)->get_storage_spec(interp, STABLE(orig_bv.val.o));
storage_spec spec;
decont_value = Rakudo_cont_decontainerize(interp, orig_bv.val.o);
spec = REPR(decont_value)->get_storage_spec(interp, STABLE(decont_value));
switch (desired_native) {
case SIG_ELEM_NATIVE_INT_VALUE:
if (spec.can_box & STORAGE_SPEC_CAN_BOX_INT) {
bv.type = BIND_VAL_INT;
bv.val.i = REPR(orig_bv.val.o)->get_int(interp, orig_bv.val.o);
bv.val.i = REPR(decont_value)->get_int(interp, decont_value);
}
else {
if (error)
Expand All @@ -330,7 +332,7 @@ Rakudo_binding_bind_one_param(PARROT_INTERP, PMC *lexpad, Rakudo_Signature *sign
case SIG_ELEM_NATIVE_NUM_VALUE:
if (spec.can_box & STORAGE_SPEC_CAN_BOX_NUM) {
bv.type = BIND_VAL_NUM;
bv.val.n = REPR(orig_bv.val.o)->get_num(interp, orig_bv.val.o);
bv.val.n = REPR(decont_value)->get_num(interp, decont_value);
}
else {
if (error)
Expand All @@ -342,7 +344,7 @@ Rakudo_binding_bind_one_param(PARROT_INTERP, PMC *lexpad, Rakudo_Signature *sign
case SIG_ELEM_NATIVE_STR_VALUE:
if (spec.can_box & STORAGE_SPEC_CAN_BOX_STR) {
bv.type = BIND_VAL_STR;
bv.val.s = REPR(orig_bv.val.o)->get_str(interp, orig_bv.val.o);
bv.val.s = REPR(decont_value)->get_str(interp, decont_value);
}
else {
if (error)
Expand All @@ -351,7 +353,13 @@ Rakudo_binding_bind_one_param(PARROT_INTERP, PMC *lexpad, Rakudo_Signature *sign
return BIND_RESULT_FAIL;
}
break;
default:
if (error)
*error = Parrot_sprintf_c(interp, "Cannot unbox argument to '%S' as a native type",
param->variable_name);
return BIND_RESULT_FAIL;
}
decont_value = NULL;
}

/* By this point, we'll either have an object that we might be able to
Expand Down

0 comments on commit 3fb9155

Please sign in to comment.