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

checker: fix struct field init with generic anon fn (fix #18294) #20888

Merged
merged 1 commit into from Feb 23, 2024

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Feb 22, 2024

This PR fix struct field init with generic anon fn (fix #18294).

pub struct Module {
}

pub struct Service {
	callback fn () = unsafe { nil }
}

pub fn (mut self Module) do_anything[T]() {
}

pub fn (mut self Module) register[T]() {
	_ := Service{
		callback: fn [mut self] [T]() {
			self.do_anything[T]()
		}
	}
}

struct Something {
}

struct SomethingDifferent {
}

fn main() {
	mut mod := Module{}
	mod.register[Something]()
	mod.register[SomethingDifferent]()
	assert true
}

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

@spytheman
Copy link
Member

Excellent.

@spytheman spytheman merged commit 0514de7 into vlang:master Feb 23, 2024
48 checks passed
@yuyi98 yuyi98 deleted the fix_generic_method_call branch February 24, 2024 04: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.

Missing generic method call generation at anonymous generic fn
2 participants