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

checker: fix nested option struct with required attr init (fix #17513) #17516

Merged
merged 1 commit into from
Mar 6, 2023

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Mar 5, 2023

This PR fix nested option struct with required attr init (fix #17513).

  • Fix nested option struct with required attr init.
  • Add test.
struct AA {
	bb ?BB // defaults to none
}

struct BB {
	x string [required]
}

fn main() {
	aa := AA{}
	println(aa)
	assert aa.bb == none
}

PS D:\Test\v\tt1> v run .
AA{
    bb: Option(error: none)
}

@spytheman spytheman merged commit 65a627d into vlang:master Mar 6, 2023
@yuyi98 yuyi98 deleted the fix_option_struct_init branch March 6, 2023 12:36
l1mey112 pushed a commit to l1mey112/v that referenced this pull request Jun 7, 2023
… struct, that has a `[required]` tag on its fields (vlang#17516)
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.

Required fields of optional structs should not require initialisation.
2 participants