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

cgen: fix struct field option type with default value init (fix #19418) #19420

Merged
merged 1 commit into from
Sep 23, 2023

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Sep 23, 2023

This PR fix struct field option type with default value init (fix #19418).

  • Fix struct field option type with default value init.
  • Add test.
type SomeType = SomeStruct | string

struct SomeStruct {}

struct AnotherStruct {
	field ?SomeType = 'default_string'
}

fn main() {
	s := AnotherStruct{}
	println(s.field)
	assert '${s.field}' == "Option(SomeType('default_string'))"
}

PS D:\Test\v\tt1> v run .
Option(SomeType('default_string'))

@spytheman spytheman merged commit 83d4614 into vlang:master Sep 23, 2023
46 checks passed
@yuyi98 yuyi98 deleted the fix_struct_option_field_init branch September 23, 2023 13:20
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.

C builderr with option as struct field.
3 participants