Skip to content

cgen: fix codegen for assigning nil or 0 to option ptr field - #24502

Merged
spytheman merged 3 commits into
vlang:masterfrom
felipensp:fix_option_nil_assign
May 18, 2025
Merged

spytheman merged 3 commits into
vlang:masterfrom
felipensp:fix_option_nil_assign

Conversation

@felipensp

@felipensp felipensp commented May 17, 2025 •

Copy link
Copy Markdown
Member

Fix #24447
Fix #24500

@felipensp felipensp changed the title cgen: fix codegen for assigning nil to option field cgen: fix codegen for assigning nil to option ptr field May 17, 2025
@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-22870

@felipensp felipensp changed the title cgen: fix codegen for assigning nil to option ptr field cgen: fix codegen for assigning nil or 0 to option ptr field May 17, 2025
@felipensp
felipensp marked this pull request as ready for review May 17, 2025 22:01

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.

Please add assertions too.

fn test_main() {
mut green_arena := Arena{}
arena_init(mut green_arena, 64 * 1024)
}

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.

Please assert that at least green_arena.data is not nil, and that green_arena.head is not nil .

@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, although the tests currently do not have assertions, they at least check that the generated C code compiles, unlike on master.

@spytheman
spytheman merged commit ef9bb8e into vlang:master May 18, 2025
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.

V compile fails with option type cgen: cannot assign nil to optional pointer fields

2 participants