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 embedded structure initialization warnings (fix #18376) #18385

Merged
merged 1 commit into from Jun 9, 2023

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Jun 9, 2023

This PR fix embedded structure initialization warnings (fix #18376).

  • Fix embedded structure initialization warnings.
  • Add test.
struct Embedded {
	a &int
}

fn new_embedded() Embedded {
	return Embedded{
		a: unsafe { nil }
	}
}

struct Outer {
	Embedded
}

fn main() {
	o := Outer{
		Embedded: new_embedded()
	}
	println(o)
}

PS D:\Test\v\tt1> v run .
Outer{
    Embedded: Embedded{
        a: &nil
    }
}

@medvednikov medvednikov merged commit 42db392 into vlang:master Jun 9, 2023
49 checks passed
@yuyi98 yuyi98 deleted the check_uninitialize_struct_field branch June 10, 2023 12:57
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.

Wrong warning "reference field must be initialized" when directly initialize embedded struct
2 participants