Repository navigation
Report the witness type of mixed as the given type - #7293
Merged
Merged
Conversation
When mixed is accepted but its witness type is not, rules now describe the witness as the given type: `return $c ? $mixed : 1;` in a function returning string reports "should return string but returns int." from level 7 instead of "returns mixed" with a tip saying mixed is int on some paths. RuleLevelHelper::accepts() checks the mixed itself first, so a mixed that is rejected on its own - explicit mixed from level 9, implicit mixed on level 10 - is still reported as mixed. RuleLevelHelperAcceptsResult carries the rejected witness type for the rules describing the given type. The native extension mirrors it. Amp-Thread-ID: https://ampcode.com/threads/T-01a237b0-3e9f-77ea-bd9b-d9a06b69686b
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.
Follow-up to the mixed witness types (
checkMixedWitnessTypes, bleeding edge).When
mixeditself is accepted but its witness type is not, the error now names the witness as the given type, without the "Type mixed is … on some paths." tip:mixedintintmixedmixedmixedintintintmixedRuleLevelHelper::accepts()checks the mixed itself first, so a mixed rejected on its own (explicit from level 9, implicit on level 10) is still reported asmixed.RuleLevelHelperAcceptsResultgets an optional?Type $witnessType, used by the rules that describe the given type: arguments, return, return after finally, property assignment and default value,yieldandyield from.RuleLevelHelper.cppmirrors it.mixedWitnesscovers returns, arguments and property assignments for explicit and implicit mixed, including nullable and union witnesses.