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
Add context to error messages #1139
Conversation
There was a problem hiding this 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); |
There was a problem hiding this comment.
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 😄
There was a problem hiding this comment.
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 if
s without them. I'd almost say without is more common. Should I change all the ones in this PR?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"); | ||
} |
There was a problem hiding this comment.
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
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 5cf5c56.
ab86372
to
5cf5c56
Compare
…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.
NQP builds ok and passes
make m-test
and Rakudo builds ok and passesmake m-test m-spectest
.