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: check struct init with pointer field (fix #18485) #18501

Merged
merged 3 commits into from Jun 21, 2023

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Jun 20, 2023

This PR check struct init with pointer field (fix #18485).

  • Check struct init with pointer field.
  • Add test.
struct Example {
	example voidptr
}

fn main() {
	println(Example{
		example: get()
	})
}

fn get() string {
	return 'hello'
}

PS D:\Test\v\tt1> v run .
tt1.v:7:3: error: cannot assign to field `example`: expected a pointer `voidptr`, but got `string`
    5 | fn main() {
    6 |     println(Example{
    7 |         example: get()
      |         ~~~~~~~~~~~~~~
    8 |     })
    9 | }

@spytheman spytheman merged commit 76ae9db into vlang:master Jun 21, 2023
49 checks passed
@yuyi98 yuyi98 deleted the check_struct_init_pointer branch June 21, 2023 12:34
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.

incorrecly assigning a string to a void pointer causes a c error
2 participants