Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add '.new()' suggestion to type object errors #1550

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/6model/reprconv.c
Expand Up @@ -66,7 +66,7 @@ void MVM_repr_set_dimensions(MVMThreadContext *tc, MVMObject *obj, MVMObject *di
OBJECT_BODY(obj), num_dims, tc->multi_dim_indices);
}
else {
MVM_exception_throw_adhoc(tc, "Cannot set dimensions on a type object");
MVM_exception_throw_adhoc(tc, "Cannot set dimensions on a type object. Did you forget a '.new'?");
}
}

Expand Down Expand Up @@ -594,7 +594,7 @@ MVMObject * MVM_repr_dimensions(MVMThreadContext *tc, MVMObject *obj) {
return result;
}
else {
MVM_exception_throw_adhoc(tc, "Cannot get dimensions of a type object");
MVM_exception_throw_adhoc(tc, "Cannot get dimensions of a type object. Did you forget a '.new'?");
}
}

Expand All @@ -607,7 +607,7 @@ MVMint64 MVM_repr_num_dimensions(MVMThreadContext *tc, MVMObject *obj) {
return num_dims;
}
else {
MVM_exception_throw_adhoc(tc, "Cannot get number of dimensions of a type object");
MVM_exception_throw_adhoc(tc, "Cannot get number of dimensions of a type object. Did you forget a '.new'?");
}
}

Expand Down Expand Up @@ -686,7 +686,7 @@ MVM_PUBLIC MVMint64 MVM_repr_get_attr_i(MVMThreadContext *tc, MVMObject *object,
MVMString *name, MVMint16 hint) {
MVMRegister result_reg;
if (!IS_CONCRETE(object))
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object", MVM_6model_get_debug_name(tc, object));
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, object));
REPR(object)->attr_funcs.get_attribute(tc,
STABLE(object), object, OBJECT_BODY(object),
type, name,
Expand All @@ -698,7 +698,7 @@ MVM_PUBLIC MVMnum64 MVM_repr_get_attr_n(MVMThreadContext *tc, MVMObject *object,
MVMString *name, MVMint16 hint) {
MVMRegister result_reg;
if (!IS_CONCRETE(object))
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object", MVM_6model_get_debug_name(tc, object));
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, object));
REPR(object)->attr_funcs.get_attribute(tc,
STABLE(object), object, OBJECT_BODY(object),
type, name,
Expand All @@ -710,7 +710,7 @@ MVM_PUBLIC MVMString * MVM_repr_get_attr_s(MVMThreadContext *tc, MVMObject *obje
MVMString *name, MVMint16 hint) {
MVMRegister result_reg;
if (!IS_CONCRETE(object))
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object", MVM_6model_get_debug_name(tc, object));
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, object));
REPR(object)->attr_funcs.get_attribute(tc,
STABLE(object), object, OBJECT_BODY(object),
type, name,
Expand All @@ -722,7 +722,7 @@ MVM_PUBLIC MVMObject * MVM_repr_get_attr_o(MVMThreadContext *tc, MVMObject *obje
MVMString *name, MVMint16 hint) {
MVMRegister result_reg;
if (!IS_CONCRETE(object))
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object", MVM_6model_get_debug_name(tc, object));
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, object));
REPR(object)->attr_funcs.get_attribute(tc,
STABLE(object), object, OBJECT_BODY(object),
type, name,
Expand All @@ -734,7 +734,7 @@ MVM_PUBLIC MVMObject * MVM_repr_get_attr_o(MVMThreadContext *tc, MVMObject *obje
MVM_PUBLIC void MVM_repr_bind_attr_inso(MVMThreadContext *tc, MVMObject *object, MVMObject *type,
MVMString *name, MVMint16 hint, MVMRegister value_reg, MVMuint16 kind) {
if (!IS_CONCRETE(object))
MVM_exception_throw_adhoc(tc, "Cannot bind attributes in a %s type object", MVM_6model_get_debug_name(tc, object));
MVM_exception_throw_adhoc(tc, "Cannot bind attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, object));
REPR(object)->attr_funcs.bind_attribute(tc,
STABLE(object), object, OBJECT_BODY(object),
type, name,
Expand All @@ -745,7 +745,7 @@ MVM_PUBLIC void MVM_repr_bind_attr_inso(MVMThreadContext *tc, MVMObject *object,
MVM_PUBLIC MVMint64 MVM_repr_attribute_inited(MVMThreadContext *tc, MVMObject *obj, MVMObject *type,
MVMString *name) {
if (!IS_CONCRETE(obj))
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object", MVM_6model_get_debug_name(tc, obj));
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, obj));
return REPR(obj)->attr_funcs.is_attribute_initialized(tc,
STABLE(obj), OBJECT_BODY(obj),
type, name, MVM_NO_HINT);
Expand Down
34 changes: 17 additions & 17 deletions src/core/interp.c
Expand Up @@ -2016,7 +2016,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(bindattr_i): {
MVMObject *obj = GET_REG(cur_op, 0).o;
if (!IS_CONCRETE(obj))
MVM_exception_throw_adhoc(tc, "Cannot bind attributes in a %s type object", MVM_6model_get_debug_name(tc, obj));
MVM_exception_throw_adhoc(tc, "Cannot bind attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, obj));
REPR(obj)->attr_funcs.bind_attribute(tc,
STABLE(obj), obj, OBJECT_BODY(obj),
GET_REG(cur_op, 2).o, MVM_cu_string(tc, cu, GET_UI32(cur_op, 4)),
Expand All @@ -2028,7 +2028,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(bindattr_n): {
MVMObject *obj = GET_REG(cur_op, 0).o;
if (!IS_CONCRETE(obj))
MVM_exception_throw_adhoc(tc, "Cannot bind attributes in a %s type object", MVM_6model_get_debug_name(tc, obj));
MVM_exception_throw_adhoc(tc, "Cannot bind attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, obj));
REPR(obj)->attr_funcs.bind_attribute(tc,
STABLE(obj), obj, OBJECT_BODY(obj),
GET_REG(cur_op, 2).o, MVM_cu_string(tc, cu, GET_UI32(cur_op, 4)),
Expand All @@ -2040,7 +2040,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(bindattr_s): {
MVMObject *obj = GET_REG(cur_op, 0).o;
if (!IS_CONCRETE(obj))
MVM_exception_throw_adhoc(tc, "Cannot bind attributes in a %s type object", MVM_6model_get_debug_name(tc, obj));
MVM_exception_throw_adhoc(tc, "Cannot bind attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, obj));
REPR(obj)->attr_funcs.bind_attribute(tc,
STABLE(obj), obj, OBJECT_BODY(obj),
GET_REG(cur_op, 2).o, MVM_cu_string(tc, cu, GET_UI32(cur_op, 4)),
Expand All @@ -2052,7 +2052,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(bindattr_o): {
MVMObject *obj = GET_REG(cur_op, 0).o;
if (!IS_CONCRETE(obj))
MVM_exception_throw_adhoc(tc, "Cannot bind attributes in a %s type object", MVM_6model_get_debug_name(tc, obj));
MVM_exception_throw_adhoc(tc, "Cannot bind attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, obj));
REPR(obj)->attr_funcs.bind_attribute(tc,
STABLE(obj), obj, OBJECT_BODY(obj),
GET_REG(cur_op, 2).o, MVM_cu_string(tc, cu, GET_UI32(cur_op, 4)),
Expand All @@ -2064,7 +2064,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(bindattrs_i): {
MVMObject *obj = GET_REG(cur_op, 0).o;
if (!IS_CONCRETE(obj))
MVM_exception_throw_adhoc(tc, "Cannot bind attributes in a %s type object", MVM_6model_get_debug_name(tc, obj));
MVM_exception_throw_adhoc(tc, "Cannot bind attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, obj));
REPR(obj)->attr_funcs.bind_attribute(tc,
STABLE(obj), obj, OBJECT_BODY(obj),
GET_REG(cur_op, 2).o, GET_REG(cur_op, 4).s,
Expand All @@ -2076,7 +2076,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(bindattrs_n): {
MVMObject *obj = GET_REG(cur_op, 0).o;
if (!IS_CONCRETE(obj))
MVM_exception_throw_adhoc(tc, "Cannot bind attributes in a %s type object", MVM_6model_get_debug_name(tc, obj));
MVM_exception_throw_adhoc(tc, "Cannot bind attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, obj));
REPR(obj)->attr_funcs.bind_attribute(tc,
STABLE(obj), obj, OBJECT_BODY(obj),
GET_REG(cur_op, 2).o, GET_REG(cur_op, 4).s,
Expand All @@ -2088,7 +2088,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(bindattrs_s): {
MVMObject *obj = GET_REG(cur_op, 0).o;
if (!IS_CONCRETE(obj))
MVM_exception_throw_adhoc(tc, "Cannot bind attributes in a %s type object", MVM_6model_get_debug_name(tc, obj));
MVM_exception_throw_adhoc(tc, "Cannot bind attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, obj));
REPR(obj)->attr_funcs.bind_attribute(tc,
STABLE(obj), obj, OBJECT_BODY(obj),
GET_REG(cur_op, 2).o, GET_REG(cur_op, 4).s,
Expand All @@ -2100,7 +2100,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(bindattrs_o): {
MVMObject *obj = GET_REG(cur_op, 0).o;
if (!IS_CONCRETE(obj))
MVM_exception_throw_adhoc(tc, "Cannot bind attributes in a %s type object", MVM_6model_get_debug_name(tc, obj));
MVM_exception_throw_adhoc(tc, "Cannot bind attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, obj));
REPR(obj)->attr_funcs.bind_attribute(tc,
STABLE(obj), obj, OBJECT_BODY(obj),
GET_REG(cur_op, 2).o, GET_REG(cur_op, 4).s,
Expand All @@ -2112,7 +2112,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(getattr_i): {
MVMObject *obj = GET_REG(cur_op, 2).o;
if (!IS_CONCRETE(obj))
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object", MVM_6model_get_debug_name(tc, obj));
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, obj));
REPR(obj)->attr_funcs.get_attribute(tc,
STABLE(obj), obj, OBJECT_BODY(obj),
GET_REG(cur_op, 4).o, MVM_cu_string(tc, cu, GET_UI32(cur_op, 6)),
Expand All @@ -2123,7 +2123,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(getattr_n): {
MVMObject *obj = GET_REG(cur_op, 2).o;
if (!IS_CONCRETE(obj))
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object", MVM_6model_get_debug_name(tc, obj));
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, obj));
REPR(obj)->attr_funcs.get_attribute(tc,
STABLE(obj), obj, OBJECT_BODY(obj),
GET_REG(cur_op, 4).o, MVM_cu_string(tc, cu, GET_UI32(cur_op, 6)),
Expand All @@ -2134,7 +2134,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(getattr_s): {
MVMObject *obj = GET_REG(cur_op, 2).o;
if (!IS_CONCRETE(obj))
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object", MVM_6model_get_debug_name(tc, obj));
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, obj));
REPR(obj)->attr_funcs.get_attribute(tc,
STABLE(obj), obj, OBJECT_BODY(obj),
GET_REG(cur_op, 4).o, MVM_cu_string(tc, cu, GET_UI32(cur_op, 6)),
Expand All @@ -2145,7 +2145,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(getattr_o): {
MVMObject *obj = GET_REG(cur_op, 2).o;
if (!IS_CONCRETE(obj))
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object", MVM_6model_get_debug_name(tc, obj));
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, obj));
REPR(obj)->attr_funcs.get_attribute(tc,
STABLE(obj), obj, OBJECT_BODY(obj),
GET_REG(cur_op, 4).o, MVM_cu_string(tc, cu, GET_UI32(cur_op, 6)),
Expand All @@ -2158,7 +2158,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(getattrs_i): {
MVMObject *obj = GET_REG(cur_op, 2).o;
if (!IS_CONCRETE(obj))
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object", MVM_6model_get_debug_name(tc, obj));
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, obj));
REPR(obj)->attr_funcs.get_attribute(tc,
STABLE(obj), obj, OBJECT_BODY(obj),
GET_REG(cur_op, 4).o, GET_REG(cur_op, 6).s,
Expand All @@ -2169,7 +2169,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(getattrs_n): {
MVMObject *obj = GET_REG(cur_op, 2).o;
if (!IS_CONCRETE(obj))
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object", MVM_6model_get_debug_name(tc, obj));
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, obj));
REPR(obj)->attr_funcs.get_attribute(tc,
STABLE(obj), obj, OBJECT_BODY(obj),
GET_REG(cur_op, 4).o, GET_REG(cur_op, 6).s,
Expand All @@ -2180,7 +2180,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(getattrs_s): {
MVMObject *obj = GET_REG(cur_op, 2).o;
if (!IS_CONCRETE(obj))
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object", MVM_6model_get_debug_name(tc, obj));
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, obj));
REPR(obj)->attr_funcs.get_attribute(tc,
STABLE(obj), obj, OBJECT_BODY(obj),
GET_REG(cur_op, 4).o, GET_REG(cur_op, 6).s,
Expand All @@ -2191,7 +2191,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(getattrs_o): {
MVMObject *obj = GET_REG(cur_op, 2).o;
if (!IS_CONCRETE(obj))
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object", MVM_6model_get_debug_name(tc, obj));
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, obj));
REPR(obj)->attr_funcs.get_attribute(tc,
STABLE(obj), obj, OBJECT_BODY(obj),
GET_REG(cur_op, 4).o, GET_REG(cur_op, 6).s,
Expand All @@ -2204,7 +2204,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(attrinited): {
MVMObject *obj = GET_REG(cur_op, 2).o;
if (!IS_CONCRETE(obj))
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object", MVM_6model_get_debug_name(tc, obj));
MVM_exception_throw_adhoc(tc, "Cannot look up attributes in a %s type object. Did you forget a '.new'?", MVM_6model_get_debug_name(tc, obj));
GET_REG(cur_op, 0).i64 = REPR(obj)->attr_funcs.is_attribute_initialized(tc,
STABLE(obj), OBJECT_BODY(obj),
GET_REG(cur_op, 4).o, GET_REG(cur_op, 6).s, MVM_NO_HINT);
Expand Down