Skip to content

cgen: fix fn call with mut reference args (fix #21265) - #21719

Merged
spytheman merged 1 commit into
vlang:masterfrom
yuyi98:fix_fn_mut_ref
Jun 24, 2024
Merged

spytheman merged 1 commit into
vlang:masterfrom
yuyi98:fix_fn_mut_ref

Conversation

@yuyi98

@yuyi98 yuyi98 commented Jun 24, 2024

Copy link
Copy Markdown
Member

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
@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