Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
throw for wrong arity in native subs
  • Loading branch information
FROGGS committed Mar 16, 2015
1 parent 4dcab36 commit 67156c1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/NativeCall.pm
Expand Up @@ -212,7 +212,17 @@ my role Native[Routine $r, Str $libname] {
$!setup = 1;
$!rettype := nqp::decont(map_return_type($r.returns));
}
nqp::nativecall($!rettype, self, nqp::getattr(nqp::decont(args), Capture, '$!list'))

my Mu $args := nqp::getattr(nqp::decont(args), Capture, '$!list');
if nqp::elems($args) != $r.signature.arity {
X::TypeCheck::Argument.new(
:objname($.name),
:arguments(nqp::p6list($args, Array, Mu).map(*.^name))
:signature(" Expected: " ~ try $r.signature.perl),
).throw
}

nqp::nativecall($!rettype, self, $args)
}
}

Expand Down

0 comments on commit 67156c1

Please sign in to comment.