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

Add type check on if-expr #3306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kamiinarii78
Copy link

Check if an if-expr return void type.

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Add check on if-expr.

gcc/testsuite/ChangeLog:

* rust/compile/implicit_returns_err3.rs: Change test to be valid.
* rust/compile/torture/if.rs: Likewise.
* rust/compile/if-without-else.rs: New test.

Fixes: #3230

Check if an if-expr return void type.

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Add check on if-expr.

gcc/testsuite/ChangeLog:

	* rust/compile/implicit_returns_err3.rs: Change test to be valid.
	* rust/compile/torture/if.rs: Likewise.
	* rust/compile/if-without-else.rs: New test.

Signed-off-by: Benjamin Thos <[email protected]>
Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good, thank you!! Just waiting on Philip to check it as he knows the typechecker :D

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 else Clause in if expr That Returns Should Produce Type Mismatch Error
3 participants