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 context to error messages #1139

Merged

Conversation

MasterDuke17
Copy link
Contributor

NQP builds ok and passes make m-test and Rakudo builds ok and passes make m-test m-spectest.

Copy link
Contributor

@bdw bdw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this definitively a positive change, but a bit messy

c_param);
}
if (!(ctx->named_used.bit_field & ((MVMuint64)1 << i)))
MVM_args_throw_named_unused_error(tc, ctx->args[ctx->num_pos + 2 * i].s);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In C, please use explicit brackets by default; as a side effect, that would've reduced the scope of the diff to contain only the block; which would've made it easier to review 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm generally a fan of explicit brackets, but the codebase has a lot of ifs without them. I'd almost say without is more common. Should I change all the ones in this PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant to say is that, if you had used, or rather left, the brackets around the block, the diff would've contained only the actual contents of the block. Which makes it easy to assert that the conditional itself hadn't changed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, I see now. Want me to add the braces back?

if (!found) {
char *c_name = MVM_string_utf8_encode_C_string(tc, name);
char *waste[] = { c_name, NULL };
MVM_exception_throw_adhoc_free(tc, waste, "setstaticlex given invalid lexical name '%s'", c_name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is such a common pattern, I wonder whether it warrants a helper function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly, but that seems like it would belong in a separate PR.

OP(sp_rebless): {
MVMObject *obj = GET_REG(cur_op, 2).o;
if (!REPR(obj)->change_type) {
MVM_exception_throw_adhoc(tc, "REPR %s (%s) cannot change type", REPR(obj)->name, MVM_6model_get_debug_name(tc, obj));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not refactor the rest of the references to obj as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Or should I just partially revert and use GET_REG(cur_op, 2).o in the arguments to MVM_exception_throw_adhoc?

else {
MVM_free(buffer);
MVM_exception_throw_adhoc(tc, "Malformed UTF-8");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the repeated free of buffer here... you could do a char first[3]; memcpy(first, buffer, MAX(bufsize, sizeof(first)) and use that? (Alternatively, add buffer as waste argument to MVM_exception_throw_adhoc_free)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 5cf5c56.

@MasterDuke17 MasterDuke17 merged commit bfe499d into MoarVM:master Sep 15, 2019
@MasterDuke17 MasterDuke17 deleted the add_context_to_error_messages branch September 15, 2019 22:37
timo added a commit that referenced this pull request Sep 16, 2019
…or_messages"

This reverts commit bfe499d, reversing
changes made to 2ac137c.
MasterDuke17 added a commit to MasterDuke17/MoarVM that referenced this pull request Oct 4, 2019
…context_to_error_messages""

This reverts commit b2dc3f3.

This was reverted because a previous commit also had to be reverted and
I wanted these changes to get their own NQP bump for easy bisecting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants