Skip to content

cgen: fix option sumtype if expr struct init#27443

Merged
medvednikov merged 1 commit into
masterfrom
fix-27440-option-sumtype-if-expr
Jun 13, 2026
Merged

cgen: fix option sumtype if expr struct init#27443
medvednikov merged 1 commit into
masterfrom
fix-27440-option-sumtype-if-expr

Conversation

@medvednikov

Copy link
Copy Markdown
Member

Summary

  • Preserve the previous struct-init cgen context when emitting nested struct init expressions.
  • Add a regression test for an option-of-sumtype field initialized via an if expression.

Fixes #27440

Testing

  • ./vnew -silent test vlib/v/tests/options/option_sumtype_if_expr_struct_field_test.v (passed before the request to skip further tests)
  • ./vnew -silent vlib/v/compiler_errors_test.v (passed before the request to skip further tests)
  • Not completed: ./vnew -silent vlib/v/gen/c/coutput_test.v (stopped after the request to stop testing)

@medvednikov medvednikov merged commit 9e35151 into master Jun 13, 2026
87 of 93 checks passed
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.

cgen: option-of-sumtype struct field initialized via if expr wraps else branch into the containing struct's type

1 participant