Commit a3d1cbb3 authored by Marius Wachtler's avatar Marius Wachtler

Don't abort when generating a call of a known type which is not callable.

fixes #1046
parent 5fd4fe6e
......@@ -141,10 +141,7 @@ public:
}
virtual CompilerVariable* call(IREmitter& emitter, const OpInfo& info, VAR* var, struct ArgPassSpec argspec,
const std::vector<CompilerVariable*>& args,
const std::vector<BoxedString*>* keyword_names) {
printf("call not defined for %s\n", debugName().c_str());
abort();
}
const std::vector<BoxedString*>* keyword_names);
virtual CompilerVariable* len(IREmitter& emitter, const OpInfo& info, VAR* var) {
printf("len not defined for %s\n", debugName().c_str());
abort();
......@@ -172,10 +169,7 @@ public:
abort();
}
CompilerType* callType(struct ArgPassSpec argspec, const std::vector<CompilerType*>& arg_types,
const std::vector<llvm::StringRef>* keyword_names) override {
printf("callType not defined for %s\n", debugName().c_str());
abort();
}
const std::vector<llvm::StringRef>* keyword_names) override;
BoxedClass* guaranteedClass() override {
ASSERT((CompilerType*)getConcreteType() != this, "%s", debugName().c_str());
return getConcreteType()->guaranteedClass();
......@@ -490,6 +484,23 @@ std::vector<CompilerVariable*> _ValuedCompilerType<V>::unpack(IREmitter& emitter
return r;
}
template <typename V>
CompilerType* _ValuedCompilerType<V>::callType(struct ArgPassSpec argspec, const std::vector<CompilerType*>& arg_types,
const std::vector<llvm::StringRef>* keyword_names) {
return UNKNOWN;
}
template <typename V>
CompilerVariable* _ValuedCompilerType<V>::call(IREmitter& emitter, const OpInfo& info, VAR* var,
struct ArgPassSpec argspec, const std::vector<CompilerVariable*>& args,
const std::vector<BoxedString*>* keyword_names) {
assert((CompilerType*)this != UNKNOWN);
ConcreteCompilerVariable* converted = makeConverted(emitter, var, UNKNOWN);
auto r = UNKNOWN->call(emitter, info, converted, argspec, args, keyword_names);
converted->decvref(emitter);
return r;
}
} // namespace pyston
#endif
......@@ -42,3 +42,24 @@ def f2():
for i in xrange(100):
f2()
# make sure we don't abort when calling a type which is not callable
def f(call):
i = 1
f = 1.0
l = 1l
s = "str"
t = (1,)
if call:
i()
f()
l()
s()
t()
try:
for i in range(10000):
f(i == 9999)
except TypeError, e:
print e
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment