Skip to content

Report a non-bool condition of the conditional operator as a type mismatch. - #1383

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_1003153382
Open

copybara-service[bot] wants to merge 1 commit into
mainfrom
test_1003153382

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Report a non-bool condition of the conditional operator as a type mismatch.

The filter, exists_one and map with a filter macros expand their predicate into the condition of _?_:_. When the predicate isn't a bool the type-checker reports found no matching overload for '_?_:_' applied to ...', which points at an operator that doesn't appear in the expression.

Report expected type 'bool' but found '<type>' at the condition instead, as is already done for the operands of && and ||.

@copybara-service
copybara-service Bot force-pushed the test_1003153382 branch 13 times, most recently from fc2d325 to 3095d1d Compare October 22, 2026 15:13
…match.

The `filter`, `exists_one` and `map` with a filter macros expand their predicate into the condition of `_?_:_`. When the predicate isn't a bool the type-checker reports `found no matching overload for '_?_:_' applied to ...'`, which points at an operator that doesn't appear in the expression.

Report `expected type 'bool' but found '<type>'` at the condition instead, as is already done for the operands of `&&` and `||`.

PiperOrigin-RevId: 1003153382
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.

0 participants