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 code generated for generic option fixed array return type #20479

Merged
merged 1 commit into from Jan 11, 2024

Conversation

felipensp
Copy link
Member

Fix #20465

fn example[T]() ?T {
	return T{}
}

fn test_main() {
	dump(example[[1]int]())

	a := example[[1]int]()
	assert a? == [0]!
}

@felipensp felipensp marked this pull request as ready for review January 11, 2024 01:37
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
Copy link
Member

A very similar test, also produces a cgen error, not sure if it is related/easy to fix:

fn example[T]() !T {
	return T{}
}

fn test_main() {
	dump(example[[1]int]()!)

	a := example[[1]int]()!
	assert a == [0]!
}

@spytheman spytheman merged commit 781d97d into vlang:master Jan 11, 2024
54 checks passed
@felipensp felipensp deleted the fix_generic_ret_fixed_array branch January 11, 2024 12:17
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 Error: Generic Result/Option Function Return Fixed Array
2 participants