From 0ee5e2e845187d11fd45f1bf367eb688799a373f Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam Date: Thu, 20 Sep 2012 15:15:26 -0700 Subject: [PATCH] Raise TypeError when a function is called with the wrong argument. Otherwise, llvm will give assertion error which is hard to trackdown. --- llvm/core.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/llvm/core.py b/llvm/core.py index d92f6d4..2aee074 100644 --- a/llvm/core.py +++ b/llvm/core.py @@ -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))