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 array of fns index call with direct_array_access mode (fix #19458) #19460

Merged
merged 1 commit into from
Sep 28, 2023

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Sep 28, 2023

This PR fix array of fns index call with direct_array_access mode (fix #19458).

  • Fix array of fns index call with direct_array_access mode.
  • Add test.
struct Bar {
	f []fn (int) int
}

fn func(n int) int {
	return n
}

[direct_array_access]
fn (b Bar) foo() int {
	return b.f[0](22)
}

fn main() {
	bar := Bar{[func]}
	ret := bar.foo()
	println(ret)
	assert ret == 22
}

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

Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@spytheman spytheman merged commit 4941a47 into vlang:master Sep 28, 2023
44 of 46 checks passed
@yuyi98 yuyi98 deleted the fix_array_fns_index_call branch September 29, 2023 00:53
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 builder error
2 participants