Repository navigation
Prettify type variables in missing constraint diagnostics - #20928
Open
ShryukGrandhi wants to merge 1 commit into
Open
ShryukGrandhi wants to merge 1 commit into
ShryukGrandhi wants to merge 1 commit into
Conversation
FS0043 printed the missing constraint without prettifying it, so unsolved inference variables showed up as '?' placeholders, e.g. 'when (^a or ^b) : (static member (+) : ^a * ^b -> '``?``)'. Fixes dotnet#6725 Signed-off-by: ShryukGrandhi <85529990+ShryukGrandhi@users.noreply.github.com>
Contributor
✅ Release notes checked
Warning No PR link found in some release notes, please consider adding it.
|
This branch has not been deployed
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.
Description
When a generic member needs a constraint it doesn't declare, FS0043 printed the constraint as-is. Unsolved inference variables then showed up as internal placeholders. For
the compiler reported
In some of the duplicate diagnostics for the same expression, the support types were also printed as
^``?```. Older compilers showed the stamp instead (^?8018`).richTextOfTyparConstraint, used only for this diagnostic, now goes through a newPrintTypes.prettyLayoutOfTyparConstraint. It attaches the constraint to a copy of the typar and runsPrettyTypes.PrettifyType, the same approachprettyLayoutOfTraitalready uses. If a member constraint's support doesn't include the typar, the typar isn't printed, so the copy gets a placeholder name. That way it can't take a name from the support types and turn^ainto^a0. The message now readsFixes #6725
Checklist
Testing
Issue 6725 - missing constraint message does not show unnamed inference variablestoErrorMessages/DiagnosticRegressionTests.fs. It fails onmain(the messages contain'``?``` and^``?```) and passes with this change.DiagnosticRegressionTests,MigratedTypeCheckTests(neg06/neg10/neg45/neg112 baselines),RecordSpreadsTests,TypeAbbreviations,CheckingOfImplementationFiles,TypeInference,TypeConstraints,IWSAM/SRTP. 486 passed. The 34 failures are all IL-baseline tests that couldn't start the x64-onlyildasmpackage on my arm64 Mac (Bad CPU type in executable), so they're unrelated to this change.