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

cgen: avoid generation of empty or block #22775

Merged
merged 4 commits into from
Nov 6, 2024
Merged

cgen: avoid generation of empty or block #22775

merged 4 commits into from
Nov 6, 2024

Conversation

StunxFS
Copy link
Contributor

@StunxFS StunxFS commented Nov 6, 2024

With this PR, code like the following:

module main

fn res() ! {}

fn main() {
	res() or {}
}

It will be generated in C like this:

VV_LOCAL_SYMBOL void main__main(void) {
        _result_void _t1 = main__res();
        (void)_t1;
 ;
}

Previously it was generated like this:

VV_LOCAL_SYMBOL void main__main(void) {
        _result_void _t1 = main__res();
        if (_t1.is_error) {
                IError err = _t1.err;
        }

 ;
}

Huly®: V_0.6-21221

Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

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

Excellent work.

Can you please also add a small test pair of .vv/.c.must_have files in vlib/v/gen/c/testdata/ ?

@felipensp
Copy link
Member

Nice. Good find.

@StunxFS
Copy link
Contributor Author

StunxFS commented Nov 6, 2024

Excellent work.

Can you please also add a small test pair of .vv/.c.must_have files in vlib/v/gen/c/testdata/ ?

@spytheman added test 👍🏽

@spytheman spytheman merged commit 37ed9dc into vlang:master Nov 6, 2024
71 checks passed
@StunxFS StunxFS deleted the cgen/remove_unused_err branch November 6, 2024 18:32
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.

3 participants