-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
checker: abstract repetitive error handling #18507
checker: abstract repetitive error handling #18507
Conversation
@@ -19,7 +19,7 @@ vlib/v/checker/tests/go_wait_or.vv:19:13: error: unexpected `or` block, the func | |||
| ~~~~~~~~~~~~~~~~~~~~~~~ | |||
20 | tg2[0].wait()? | |||
21 | tg3 := [ | |||
vlib/v/checker/tests/go_wait_or.vv:20:15: error: unexpected `?`, the function `wait` does not return an Option or a Result |
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.
The error handlers already had explicitly checked if we .propagate_option
or .propagate_result
.
I assume we therefore don't need the or a Result
. Other errors already have taken that into account and ended with just an Option
. It was just this error that went out of the line.
@@ -26,7 +26,7 @@ vlib/v/checker/tests/struct_field_option_err.vv:16:19: error: last statement in | |||
| ^ | |||
17 | | |||
18 | _ = f.baz? | |||
vlib/v/checker/tests/struct_field_option_err.vv:18:11: error: unexpected `?`, the field `baz` is neither an Option, nor a Result |
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.
Due to the abstraction this was adapted to be uniform with the predominantly used phrasing is not ...
The As long as the error matches the type... |
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.
Good work.
🤖 Generated by Copilot at 569b52a
This pull request refactors and simplifies the error reporting and checking logic for various expressions involving stack objects,
or
blocks,?
and!
operators in the V compiler. It extracts two common functionsexpr_or_block_err
andfail_if_stack_struct_action_outside_unsafe
invlib/v/checker/checker.v
and reuses them in other modules. It also updates the error messages and the corresponding tests to be more specific and consistent.🤖 Generated by Copilot at 569b52a
fail_if_stack_sturct_action_outside_unsafe
invlib/v/checker/checker.v
(link, link)fail_if_stack_sturct_action_outside_unsafe
to simplify the code invlib/v/checker/assign.v
,vlib/v/checker/return.v
, andvlib/v/checker/struct.v
(link, link)expr_or_block_err
invlib/v/checker/checker.v
that handles the error reporting for unexpectedor
blocks,?
and!
operators when the expression is not an Option or a Result (link)expr_or_block_err
to simplify the code and improve the error messages invlib/v/checker/checker.v
for function call expressions, selector expressions, go statements, and struct init expressions (link, link, link, link)vlib/v/checker/tests/go_wait_or.out
,vlib/v/checker/tests/struct_field_option_err.out
, andvlib/v/checker/tests/unexpected_or_propagate.out
to match the new error messages generated by the new functionexpr_or_block_err
(link, link, link, link)