Commit 7b06e12e authored by Marius Wachtler's avatar Marius Wachtler

add refcounting annotations to sum()

parent 44f2e0f7
......@@ -296,18 +296,19 @@ extern "C" Box* next(Box* iterator, Box* _default) noexcept {
}
extern "C" Box* sum(Box* container, Box* initial) {
assert(0 && "check refcounting");
if (initial->cls == str_cls)
raiseExcHelper(TypeError, "sum() can't sum strings [use ''.join(seq) instead]");
static RuntimeICCache<BinopIC, 3> runtime_ic_cache;
std::shared_ptr<BinopIC> pp = runtime_ic_cache.getIC(__builtin_return_address(0));
Box* cur = initial;
Py_INCREF(initial);
auto cur = autoDecref(initial);
for (Box* e : container->pyElements()) {
AUTO_DECREF(e);
cur = pp->call(cur, e, AST_TYPE::Add);
}
return cur;
return incref(cur.get());
}
extern "C" Box* id(Box* arg) {
......
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