Commit 4881de13 authored by Boxiang Sun's avatar Boxiang Sun

use new callattr to find attribute function, and add error check

parent f07534a2
...@@ -4378,10 +4378,11 @@ extern "C" Box* unaryop(Box* operand, int op_type) { ...@@ -4378,10 +4378,11 @@ extern "C" Box* unaryop(Box* operand, int op_type) {
BoxedString* op_name = getOpName(op_type); BoxedString* op_name = getOpName(op_type);
// TODO: this code looks very old and like it should be a callattr instead? CallattrFlags callattr_flags{.cls_only = true, .null_on_nonexistent = true, .argspec = ArgPassSpec(0) };
Box* attr_func = getclsattrInternal(operand, op_name, NULL); Box* rtn = callattr(operand, op_name, callattr_flags, NULL, NULL, NULL, NULL, NULL);
RELEASE_ASSERT(attr_func, "%s.%s", getTypeName(operand), op_name->c_str()); if (rtn == NULL) {
Box* rtn = runtimeCallInternal<CXX>(attr_func, NULL, ArgPassSpec(0), NULL, NULL, NULL, NULL, NULL); raiseExcHelper(TypeError, "bad operand type for unary '%s': '%s'", op_name->c_str(), getTypeName(operand));
}
return rtn; return rtn;
} }
......
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