Skip to content

checker: clean up ensure_type_exists()#18860

Merged
spytheman merged 2 commits intovlang:masterfrom
yuyi98:cleanup_ensure_type_exists
Jul 14, 2023
Merged

checker: clean up ensure_type_exists()#18860
spytheman merged 2 commits intovlang:masterfrom
yuyi98:cleanup_ensure_type_exists

Conversation

@yuyi98
Copy link
Copy Markdown
Member

@yuyi98 yuyi98 commented Jul 14, 2023

This PR clean up ensure_type_exists().

Comment thread vlib/v/checker/interface.v Outdated
Comment thread vlib/v/checker/interface.v Outdated
Comment thread vlib/v/checker/interface.v Outdated
Comment thread vlib/v/checker/tests/any_int_float_ban_err.out
Comment thread vlib/v/checker/checker.v
@spytheman
Copy link
Copy Markdown
Contributor

spytheman commented Jul 14, 2023

I am not sure that changing ? to false is simpler in all aspects.
In terms of implementation, a boolean is simpler than an option.
However, with that change, the call sites now look like this:

	- c.ensure_type_exists(arg.typ, arg.type_pos) or { return }
	+ if !c.ensure_type_exists(arg.typ, arg.type_pos) {
	+	return
	+ }

@yuyi98
Copy link
Copy Markdown
Member Author

yuyi98 commented Jul 14, 2023

Minimize the use of option for frequently invoked functions for the performance.

@yuyi98
Copy link
Copy Markdown
Member Author

yuyi98 commented Jul 14, 2023

There is a problem with using return instead of return none in the original ensure_type_exists(...) ?, so or { return } doesn't work correctly.

@spytheman spytheman merged commit b06811c into vlang:master Jul 14, 2023
@yuyi98 yuyi98 deleted the cleanup_ensure_type_exists branch July 16, 2023 03:23
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