Skip to content

Conversation

lowr
Copy link

@lowr lowr commented Oct 12, 2025

Fixes #3927

This PR fixes type checking on tuple indexing expressions by properly emitting errors when the tuple operand of the expression is not tuple-like instead of an assertion that was causing the reported panic. Although not reported by the issue, I also found that the previous code allowed tuple indexing on structs, so I added a test case to assert such expressions also cause compilations to fail with an appropriate error message.

In addition, I fixed the clang-format version to use in CONTRIBUTING.md. Let me know if the commit should be in a separate PR since it's irrelevant to #3927.

@lowr lowr force-pushed the fix/tuple-index-reject-non-tuple branch from ee531b7 to 269ec48 Compare October 12, 2025 10:24
Fixes Rust-GCC#3927

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): check
	and properly emit an error when the tuple index is on a non-tuple-struct.

gcc/testsuite/ChangeLog:

	* rust/compile/tuple_index_on_non_tuple.rs: New test.

Signed-off-by: Ryo Yoshida <[email protected]>
@lowr lowr force-pushed the fix/tuple-index-reject-non-tuple branch from 269ec48 to 3dbc08f Compare October 12, 2025 10:26
@dkm
Copy link
Member

dkm commented Oct 13, 2025

Not a big deal, but the doc change for clang-format version could be split in a different PR.

@lowr
Copy link
Author

lowr commented Oct 13, 2025

Sure, I'll drop the second commit and submit another PR then :)

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.

ICE in visit, at rust/typecheck/rust-hir-type-check-expr.cc

2 participants