Skip to content

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

Merged
copybara-service[bot] merged 1 commit into
mainfrom
test_1003153382
Oct 23, 2026
Merged

copybara-service[bot] merged 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 17 times, most recently from 08283fd to 2d0ba46 Compare October 23, 2026 15:53
…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: 1005646592
@copybara-service
copybara-service Bot merged commit 90cd1ed into main Oct 23, 2026
6 checks passed
@copybara-service
copybara-service Bot deleted the test_1003153382 branch October 23, 2026 16:12
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