Skip to content

cgen, checker: fix option unwrapping and call from option struct field#23182

Merged
spytheman merged 2 commits intovlang:masterfrom
felipensp:fix_option_method_call_selector
Dec 17, 2024
Merged

cgen, checker: fix option unwrapping and call from option struct field#23182
spytheman merged 2 commits intovlang:masterfrom
felipensp:fix_option_method_call_selector

Conversation

@felipensp
Copy link
Copy Markdown
Member

@felipensp felipensp commented Dec 16, 2024

Make works:

struct Foo {
mut:
	func ?fn (voidptr) ?bool = unsafe { nil }
}

fn callback(foo &Foo) ?bool {
	return foo.func? == callback
}

fn test_main() {
	t := Foo{
		func: callback
	}
	assert t.func? == callback
	if t.func != none {
		assert t.func(&t)
	} else {
		assert false
	}
}

Huly®: V_0.6-21619

@felipensp
Copy link
Copy Markdown
Member Author

The CI failure is related to missing fix from PR #23179 (not merged yet)

@felipensp felipensp marked this pull request as ready for review December 16, 2024 13:02
@spytheman spytheman force-pushed the fix_option_method_call_selector branch from 901881b to 5e7651b Compare December 17, 2024 07:08
Copy link
Copy Markdown
Contributor

@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 719fa4d into vlang:master Dec 17, 2024
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.

2 participants