Skip to content

cgen: avoid generation of empty or block - #22775

Merged
spytheman merged 4 commits into
vlang:masterfrom
StunxFS:cgen/remove_unused_err
Nov 6, 2024
Merged

spytheman merged 4 commits into
vlang:masterfrom
StunxFS:cgen/remove_unused_err

Conversation

@StunxFS

@StunxFS StunxFS commented Nov 6, 2024 •

Copy link
Copy Markdown
Contributor

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

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Member

Nice. Good find.

@StunxFS

StunxFS commented Nov 6, 2024

Copy link
Copy Markdown
Contributor Author

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
@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