Raise TypeError when a function is called with the wrong argument.
Otherwise, llvm will give assertion error which is hard to trackdown.
This commit is contained in:
parent
e7ad6c7439
commit
0ee5e2e845
1 changed files with 5 additions and 0 deletions
|
|
@ -2067,6 +2067,11 @@ class Builder(object):
|
|||
|
||||
def call(self, fn, args, name=""):
|
||||
check_is_callable(fn)
|
||||
|
||||
err_template = 'Argument type mismatch: expected %s but got %s'
|
||||
for i, (t, v) in enumerate(zip(fn.type.pointee.args, args)):
|
||||
if t != v.type:
|
||||
raise TypeError(err_template % (t, v.type))
|
||||
arg_ptrs = unpack_values(args)
|
||||
return _make_value(
|
||||
_core.LLVMBuildCall(self.ptr, fn.ptr, arg_ptrs, name))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue