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 option map with fn type value (fix #18786) #18849

Merged
merged 1 commit into from
Jul 12, 2023

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Jul 12, 2023

This PR fix option map with fn type value (fix #18786).

  • Fix option map with fn type value.
  • Add test.
const mouse_action_to_function_map = {
	1: handle_mouse_down_signal
}

fn handle_mouse_down_signal() string {
	return 'hello'
}

fn main() {
	t := mouse_action_to_function_map[1] or { return }
	println(t())
	assert t() == 'hello'
}

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

@spytheman spytheman merged commit 52a055b into vlang:master Jul 12, 2023
49 checks passed
@yuyi98 yuyi98 deleted the fix_map_value_fn_var branch July 12, 2023 14:18
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.

or { return } C error for map when value has function type
2 participants