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 fn call with mut reference args (fix #21265) #21719

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Jun 24, 2024

This PR fix fn call with mut reference args (fix #21265).

  • Fix fn call with mut reference args.
  • Add test.
@[heap]
struct Client {
mut:
	next &Client = unsafe { nil }
	prev &Client = unsafe { nil }
}

fn init_vm1(mut head &Client) {
	for c := head; c; c = c.next {
	}
}

fn init_vm2(mut head &Client) {
	for c := head; c == unsafe { nil }; c = c.next {
	}
}

fn main() {
	mut head := &Client{}
	init_vm1(mut head)
	init_vm2(mut head)
	assert true
}

PS D:\Test\v\tt1> v run .

@spytheman spytheman added the Unit: cgen Bugs/feature requests, that are related to the default C generating backend. label Jun 24, 2024
@spytheman spytheman merged commit 4d2c2da into vlang:master Jun 24, 2024
76 checks passed
@yuyi98 yuyi98 deleted the fix_fn_mut_ref branch June 24, 2024 09:28
raw-bin pushed a commit to raw-bin/v that referenced this pull request Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Unit: cgen Bugs/feature requests, that are related to the default C generating backend.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

struct reference mutable function argument builder problem
2 participants