Repository navigation
checker: validate or-block defaults before outer casts - #27059
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #27054
This patch fixes or-block fallback validation when an Option/Result expression is used inside an outer cast. The checker now validates the or-block default against the original unwrapped payload type, instead of letting the outer cast type leak into the fallback check. This covers both call expressions like
int(result_f64() or { 3.0 })and selector expressions likeint(holder.x or { 3.0 }), with tests for literals, aliases, generics, parentreturn,none,error(...), and invalid fallback types.Explicitly out of scope:
h.x or {}andh.x or { side_effect }, because those are rejected earlier byselector_expr. Supporting that form would be a separate language/checker decision about whether selectoror {}blocks without a value should be allowed, and that is not something I should decide in this patch. Also, struct fields cannot currently store Result types (!T), so there is nor !f64selector-field test.