-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ConstraintSystem] Improve connected components printing in the type inference algorithm debug output #59971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
xedin
merged 8 commits into
swiftlang:main
from
amritpan:improve-connected-components-printing
Aug 23, 2022
+207
−44
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
67d807d
[CSStep] List type variables in scope under consideration for each co…
e3e446b
[CSStep] Remove previous "Initial binding" output.
177f136
[CSStep] Add disjunction and conjunction printing to initial state di…
bd2968e
[ConstraintGraph] Make Changes member types public and create accesso…
01ea11b
[ConstraintGraph] Collect and print changes in current Active Scope.
d750d38
[CSBindings] Consolidate BindingSet dump into single function.
51281c5
[CSBindings] Move binding printing out of determineBestBindings and c…
6d55c52
[Test] Update failing test.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -346,8 +346,45 @@ StepResult ComponentStep::take(bool prevFailed) { | |
|
||
/// Try to figure out what this step is going to be, | ||
/// after the scope has been established. | ||
SmallString<64> potentialBindings; | ||
llvm::raw_svector_ostream bos(potentialBindings); | ||
|
||
auto bestBindings = CS.determineBestBindings([&](const BindingSet &bindings) { | ||
if (CS.isDebugMode() && bindings.hasViableBindings()) { | ||
bindings.dump(bos, CS.solverState->getCurrentIndent() + 2); | ||
} | ||
}); | ||
|
||
auto *disjunction = CS.selectDisjunction(); | ||
auto bestBindings = CS.determineBestBindings(); | ||
auto *conjunction = CS.selectConjunction(); | ||
|
||
if (CS.isDebugMode()) { | ||
PrintOptions PO; | ||
PO.PrintTypesForDebugging = true; | ||
|
||
auto &log = getDebugLogger(); | ||
if (!potentialBindings.empty()) { | ||
log << "(Potential Binding(s): " << '\n'; | ||
log << potentialBindings; | ||
} | ||
log.indent(CS.solverState->getCurrentIndent()); | ||
|
||
if (disjunction) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This and conjunction section prints a selected disjunction/conjunction instead of all of them but let’s address that in a follow up PR instead of holding this one. |
||
log.indent(2); | ||
log << "Disjunction(s) = ["; | ||
auto constraints = disjunction->getNestedConstraints(); | ||
log << constraints[0]->getFirstType()->getString(PO); | ||
log << "]"; | ||
} | ||
if (conjunction) { | ||
log.indent(2); | ||
log << "Conjunction(s) = ["; | ||
auto constraints = conjunction->getNestedConstraints(); | ||
log << constraints[0]->getFirstType()->getString(PO); | ||
log << "]"; | ||
} | ||
log << ")\n"; | ||
} | ||
|
||
if (CS.shouldAttemptFixes()) { | ||
if ((bestBindings && | ||
|
@@ -486,23 +523,6 @@ StepResult ComponentStep::finalize(bool isSuccess) { | |
|
||
void TypeVariableStep::setup() { | ||
++CS.solverState->NumTypeVariablesBound; | ||
if (CS.isDebugMode()) { | ||
PrintOptions PO; | ||
PO.PrintTypesForDebugging = true; | ||
auto &log = getDebugLogger(); | ||
|
||
auto initialBindings = Producer.getCurrentBindings(); | ||
log << "Initial bindings: "; | ||
interleave( | ||
initialBindings.begin(), initialBindings.end(), | ||
[&](const Binding &binding) { | ||
log << TypeVar->getString(PO) | ||
<< " := " << binding.BindingType->getString(PO); | ||
}, | ||
[&log] { log << ", "; }); | ||
|
||
log << '\n'; | ||
} | ||
} | ||
|
||
bool TypeVariableStep::attempt(const TypeVariableBinding &choice) { | ||
|
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.