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

ast, parser: fix generic fn type with different generic type call (fix #22306) #22431

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Oct 7, 2024

This PR fix generic fn type with different generic type call (fix #22306).

  • Fix generic fn type with different generic type call.
  • Add test.
type Fn[T] = fn () T

fn problem[X](f Fn[X]) X {
	return f[X]()
}

fn foo() int {
	return 1
}

fn main() {
	t := problem[int](foo)
	println(t)
}

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

@yuyi98 yuyi98 changed the title ast, parser: fix generic fn type with defferent generic type call (fix #22306) ast, parser: fix generic fn type with different generic type call (fix #22306) Oct 7, 2024
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 3736e51 into vlang:master Oct 7, 2024
78 checks passed
@yuyi98 yuyi98 deleted the fix_generic_fntype branch October 7, 2024 08:11
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.

function type generic cannot have a different generic letter when used as a parameter
2 participants