Skip to content

checker: fix cast from an empty struct to option (fix #25566)#25581

Merged
spytheman merged 7 commits into
vlang:masterfrom
StunxFS:checker/fix-empty-struct-option-init
Oct 24, 2025
Merged

checker: fix cast from an empty struct to option (fix #25566)#25581
spytheman merged 7 commits into
vlang:masterfrom
StunxFS:checker/fix-empty-struct-option-init

Conversation

@StunxFS

@StunxFS StunxFS commented Oct 24, 2025

Copy link
Copy Markdown
Contributor
$ cat x.v
struct Struct {}

fn main() {
        s := ?Struct(Struct{})
        a := s or { panic('none') }
        println(a)
        assert a == Struct{}
}
$ ./v run x.v
Struct{}

Fix #25566.

@StunxFS StunxFS marked this pull request as draft October 24, 2025 13:38
@StunxFS StunxFS marked this pull request as ready for review October 24, 2025 18:42

@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.
Thank you.

@spytheman spytheman merged commit 3e628d0 into vlang:master Oct 24, 2025
84 checks passed
@StunxFS StunxFS deleted the checker/fix-empty-struct-option-init branch October 24, 2025 19:36
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.

unable to init an empty option struct

2 participants